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

Script to check frames

Status
Not open for further replies.

spicysudhi

Programmer
Nov 10, 2003
575
FR
Hi

I have pages Index.htm, menu.htm and body.htm

here index.htm got the frame definitions. window splitted to 2 frames, and pages in them are menu.htm and body.htm

I want users to force to come thru the index.htm and prevent them from directly accessing body.htm. So I need a script in body.htm which checks whether page is in a frame or not. If not in frame, i want to reload with index.htm.

can someone please help me in writing this script. thanks in advance

regards,
sudhi
 

Make the body tag of "body.htm" like this:

Code:
<body onload="if(top.location.indexOf('/index.html')==-1) top.location='/index.html';">

Hope this helps,
Dan
 
object doesnot support this property ot method - error

regards,
sudhi
 
My apologies - change "top.location.indexOf" to "top.location.href.indexOf".

I had assumed that JS would have executed the toString() method of the location object - but I guess it didn't!

Hope this helps,
Dan
 
If being able to print body.htm is important:
Check to be sure you can print body.htm in netscape.
I have found that Netscape will execute the redirect even when trying to print the page and as a result generate an error.

I had to put it in a doc.write statement like this:
function reloadF()
{
location.replace(index.html);
}
if (parent.frames.length == 0)
{
document.write("<\/HEAD>");
document.write('<BODY ONLOAD="reloadF();"');
document.write("<\/BODY><\/HTML>");
document.close();
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top