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

how to determine if page has frames...

Status
Not open for further replies.

spewn

Programmer
May 7, 2001
1,034
i want to run a test to see if the page is in frames, so if frames, then action 1 happens, but if no frames are present, it won't say window.top.frames.nav.document is not an object.

help...

-crispy
 
Hi crispyhippo,

You just have to use this sample: (it seems to work both on NN and IE)

if (window.top.frames['first_frame']) {
... action1 ...
}

or

if (window.top.frames['first_frame'].document.location == "myPage.htm") {
... action1 ...
}

The first one is to know if the frame exists and the second, to check the page in it!

Hope this helps....
 
hi guyz
no SeAl, i think crispyhippo meaned that he wants 2 know if yhe current page is in frameset at all, but not if it is in the exact frame named 'firstframe'; so, i think (didnt checked this, just a suggestion) that he is able of doin that this way:
if (top.frames.length>0){/* there is a frameset */}
else {/* there is no frameset */}

regards, vic
 
Hi vituz,

It's exactly the same thing as:

if (window.top.frames['first_frame']) {
... action1 ...
}
 
hie
well, am missin smth?
i read ur code as follows:
if (window.top.frames['first_frame']) {
... action1 ...
}

means:
if window has a frame named 'first_frame' then i do action1
am i wrong??
& my suggestion:
if (top.frames.length>0){/* there is a frameset */}
reads as if document's frames array has at least 1 item then i do smth

ps i'm not tellin that u're wrong, i just think that crispyhippo wanted just a bit different from what u're suggestin.. regards, vic
 
so just do it like window.top.frames[0] ;-)
 
agree
cheers.gif
regards, vic
 
hey, wanted to know if you can break these down for me, (meaning, function).

I am new to the .length and [0]...

thanks.

***

if (top.frames.length>0)

window.top.frames[0]

***

thanks for the info previous. -crispy
 
what do u mean?
here is the function:
function checkforframes(){
if (top.frames.length>0) alert('this page is in frameset')
else alert('no frameset here')
}
onload=checkforframes

??? regards, vic
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top