PDA

View Full Version : iframe/javascript disabling back button


Nathan00
11-09-2005, 05:40 PM
First time poster, so be easy on me! :)

Okay, so I've just installed a javascript that redirects to any random page from a specified list. The problem with it is, it's in an iframe and works as sort of an advertising area. So on the mainpage where the iframe has been placed, whenever someone uses the back button, it just keep going back in the iframe and choosing random pages. The back button doesn't work on the mainpage and instead is used in the actual iframe.

I'm not sure if this is a problem with the iframe or the script, and I don't think I have the mental capacity to figure it out so I'd really value some help! Oh, and apparently the problem doesn't occur when using Firefox.

The script is being used @ http://thetvforums.com and you'll be able to see the iframe used for the "Featured" box in the top right-hand corner.

The script that I've used is below and the address of that is http://thetvforums.com/featured/index.html (this is what the iframe opens when its initialized, then this page randomly selects the new pages).

<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1250">
<title></title>
</head>
<body leftmargin="0" topmargin="0" rightmargin="0" marginwidth="0" marginheight="0" onload="go()">

<SCRIPT LANGUAGE="JavaScript">
var urlarray= new Array(
"dvd1.html",
"dvd2.html",
"dvd3.html",
"show1.html",
"show2.html");

randomno=Math.floor((Math.random()*urlarray.length));

urlran=urlarray[randomno]

</SCRIPT>
<SCRIPT LANGUAGE="JavaScript">
function go(){
var url=urlran
var target="_self"
window.open(url,target)
}
</SCRIPT>

</body>

</html>

Lerura
11-09-2005, 08:46 PM
make this your full page coding:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head><title></title>
<script type="text/javascript"><!--

var urlarray= new Array(
"dvd1.html",
"dvd2.html",
"dvd3.html",
"show1.html",
"show2.html");

randomno=Math.floor((Math.random()*urlarray.length));

urlran=urlarray[randomno];

window.location.replace(urlran);

// --></script>
</head>
<body>
</body>
</html>

(tested and validated)

Nathan00
11-10-2005, 02:50 AM
That worked perfectly! Thank you soooo much. I was really worried about it and you just lifted a huge weight. Thanks... :thumbsup: