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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Break out of Frames

Status
Not open for further replies.

moepower

Programmer
Oct 5, 2000
93
US
What's the best way to break out of frames for a .jsp page? I thought about using the following but it does not work for my case. Thanks,

onLoad="if(parent.frames.length!=0)top.location='pagename.html';"

 
It depends on where you are putting the onLoad event handler. Is that going in the frameset pages or one of the frames pages ?? Also, there's a slight syntax problem with your if() method, but I would encourage you to execute if() conditions within functions instead of directly in the event handler. More on that later. Where is the onLoad event handler placed??

ToddWW
 
I'm sorry. What I meant was in which <body> tag ? The one in the frameset page, or the one in one of the frames pages ??

ToddWW
 
Sorry, I didn't read it closely enough.

What I'm trying to do is if I send my webpage link to a MS Hotmail account. When the user click on the link, it will break out of the Hotmail frame. So I take it that it's a frameset page?
 
Just write these few lines in between your <head></head> tags and see if this works. No need for the onLoad event handler so get rid of that..
Code:
<head>
<script Language=&quot;JavaScript&quot;>
<!--
if(top != self) {
  top.location = location
}
//-->
</script>
</head>
If you have a problem with that, change the top references to parent starting with the top.location to parent.location.

ToddWW

 
or...

<SCRIPT><!--
if (top.location!=this.location) {top.location=this.location}
//--></SCRIPT>
 
or

<SCRIPT>
<!--
if (top.length) {top.location.href=self.location.href}
//-->
</SCRIPT> Victor
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top