Invision-Graphics Forums

Programming – How to break out of Frames or Someone Else's Frames?

martyk9 – Sun Feb 03, 2008 6:48 pm
Post subject: – How to break out of Frames or Someone Else's Frames?

I hope this is in the right thread, I have a problem with a web site using frames to pull my site and content to load within their website. Their using some sort of Frames to load my content within their website without my permission.

I tried searching but couldn't find a solution that works to fix my problem, any help would be appreciated...

Marty Uh Ohh Admin – Sun Feb 03, 2008 7:07 pm
Post subject: – Re: How to break out of Frames or Someone Else's Frames?

Hello Marty Smile

This can be annoying but there is an easy solution to get around it. You can use JavaScript within your web pages to break out of Frames.

This is how...JavaScript Method, Now be sure to place it between the <HEAD> tags </HEAD> of your web page ...

Code:

<script language="JavaScript">
<!-- Breaks users out of frames. Put this under the body tag -->
<!-- Hide script from older browsers
setTimeout ("changePage()", 3000);

function changePage() {
if (self.parent.frames.length != 0)
self.parent.location="http://yourpage.com";
}
// end hiding contents -->

</script>



The best method that I would suggest is to use the following.

Step 1. Open notepad up and paste the following in

Code:

function breakout_frame()
{
  if (top.location != location) {
    top.location.href = document.location.href ;
  }
}



Step 2. Close notepad and save it as breakout.js

Step 3. Upload the breakout.js file to your root directory of your website.

Step 4. Include the JS script within your website by using the following

Code:

<script src="breakout.js" language="JavaScript" type="text/javascript">
</script>


It should be placed in the <head> section of your web page..

Step 5. Place the function breakout_frame() in the <body> tag like so, by replacing <body> with the following body tag....

Code:
<body onload="breakout_frame()">


This will load the JavaScript JS file on each page load, so if your web pages are loading inside someone else's frames it will force the page to break out of frames.

There is also a None JavaScript Method: Use a Meta Tag that the user can click to break out of the other sites frames by using the following..

Code:
<META HTTP-EQUIV="Window-target" CONTENT="_top">Break out of a frame</a>


Hope this helps and report back if you need any further help!

Shawn DesRochers Smile martyk9 – Mon Feb 04, 2008 5:56 pm
Post subject: – Re: How to break out of Frames or Someone Else's Frames?

Shawn you are awesome...my friend.

Your second option is the one I went with and it did the trick, works great!

Thanks for all your help.

Marty Big Smile Shocked
All times are GMT - 5 Hours
Forums Maintained by Invision-Graphics Inc © 2008