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

Determine in or not in frame.

Status
Not open for further replies.

DarkKodiak

Programmer
Feb 2, 2003
15
0
0
US
Hi,

I have a site that uses frames. I dont want any of my pages to be orphans. I am trying to write a script that determines if a page is in or not in a frame. So far I am doign this:

if (top.location==self.location)
{
frame this page code goes here.
}

This sort of works, but even when the page is framed the if statement returns true...what am I doing wrong?
 
Pete,

Can you please explain? Where do I put the return?
 
Code:
function notInFrame(){
  return (0 == window.parent.frames.length) 
}

Then in your script code:
Code:
if( notInFrame()){
... do whatever you desire when this page is in a frame
}

-pete
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top