...

View Full Version : I have a "Put In Frame Script" here but it needs a tweak



Dean
10-20-2003, 03:10 PM
Hi there

this script breaks a page out of a frame, i want to reverse this so that if the page is not in a frame it will go and fetch the correct frame.

this is the bustframe script:

<script language="JavaScript" type="text/JavaScript">
<!--
function BustFrames() {
if (self.parent.frames.length!=0)
{
self.parent.location.replace(document.location.href);
}
}
//-->
</script>

I figure that if i swap a few bits round like so:

<script language="JavaScript" type="text/JavaScript">
<!--
function AW_BustFrames() {
if (self.parent.frames.length!=1 )
{
self.parent.location.replace(document.location.href); ;
}
}
//-->
</script>

By changing the 0 to 1 i hoping this will mean if it is not in a fram then do the second bit in red but i need this bit to go to a url that i type in.

So can anybody help me with this one.:confused: :confused:

cheers dean

requestcode
10-20-2003, 03:27 PM
Here is one that I got from somebody in this forum. The first part checks to see if the page is not in a frame. If it is not then it redirects to the frameset with the location attached to the URL.:
<html>
<head>
<title>Force Frames Test</title>
<script language="JavaScript">
if (self == top)
{
var url = self.location;
self.location = "http://www.mysite.com/frset.html?" + url;
}
</script>
</head>
<body>

</body>
</html>

In the frameset you then have code to check if there is a value attached to the URL. If there is it then loads that page into the frame.

<html>
<head>
<title>Frame Print Demo</title>
<script language="JavaScript">
function frame_saver()
{
if (self.location.search)
{
parent.frameb.location = location.search.substring(1,location.search.length);
}
}
window.onload = frame_saver;
</script>
</head>
<frameset rows="25%,*" border="1">
<frame src="looka.html" name="framea">
<frame src="lookb.html" name="frameb">
</frameset>

"frameb" has a defualt page in case there is not a value attached to the URL.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum