Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Force Frame on Top

Status
Not open for further replies.

BobbaFet

Programmer
Feb 25, 2001
903
NL
How can I make sure that my framset ALWAYS ends up being
the only frameset in the browser. This to prevent my
frameset being loaded in another.

Bobba_Fet Everybody has a right to my opinion.
E-mail me at cwcon@programmer.net
 
Use this javascript in your frameset:
Code:
<script language=&quot;JavaScript&quot;>
if ( top.location != self.location )
   top.location = self.location;
</script>
Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
There is a script called a frame buster script, cnn uses it. I've copied it below for you:

<script language=&quot;JavaScript&quot; type=&quot;text/javascript&quot;>
<!-- Hide script from older browsers
setTimeout (&quot;changePage()&quot;, 3000);

function changePage() {
if (self.parent.frames.length != 0)
self.parent.location=document.location;
}

// end hiding contents -->
</script>

Once this is placed between the head tags, any time someone tries to frame your site, it will take about 1.5 to 2 seconds and your site will bust out of the frame and open to a full browser window. The other thing that happens is it will be almost impossible for the user to use their back button to return to the site that had you framed as everytime they return to the frameset that had you framed, your site will bust out and open a full window (not a new window) the same window just with your site filling the entire screen.

Hope this helped!
 
Sounds like pretty much the same thing as the code I posted does. But why wait a few seconds to do it?
Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
Thanx allot both of you,

You have helped me a great deal.
Just gotta love this forum ;-)

Bobba_Fet Everybody has a right to my opinion.
E-mail me at cwcon@programmer.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top