PDA

View Full Version : Force load a page in frames...


three
10-12-2001, 04:09 PM
I want to make sure a page is always displayed within it's frames. For example if you view "page.html" alone, I want it to automatically check and then reload it within a specified frameset. Does anybody have the javascript for this?

I tried using the following script, but it doesn't work on a mac (it repeatedly refreshes forever).

<SCRIPT>
function checkStatus() {
page = self.location.href;
if (page != "index.html") {
top.location.href = "index.html";
return true;
}
}
</SCRIPT>

<body onLoad="checkStatus()";>

thanks

janderk
10-13-2001, 02:32 PM
Originally posted by three:
I want to make sure a page is always displayed within it's frames.

This should do it:
<head>
<script language="JavaScript">
<!--
if (parent.location.href == self.location.href)
window.location.href = 'index.html';
//-->
</script>
</head>

Jan Derk

Rich
10-14-2001, 04:31 AM
Hmmmm... since a page cannot display itself within a frameset, you will need to call the page that contains the frameset, rather than (re-)calling index.html.

Rich

Harley
10-14-2001, 10:50 AM
In this case "index.html" is the frameset page ... if your frameset page is called something other than "index.html", put it in that window.location.href = 'index.html'; instead.

BTW, that Javascript needs to be on the actual page, not in a linked .js file, or you will get the constantly refreshing page in N4 / Mac.

Regards!

Harley