PDA

View Full Version : script works in IE but not in Firefox, why



zoffmann
12-21-2007, 09:39 AM
I got the following script to adapt it, but I discovered that the script doesn't work in firefox, I wonder why.

The script is supposed to change pages automatically in browser for given amount of time. Try it in IE.

Any help is appreciated.


<html>
<head>
<title>URL Switcher</title>


<script language="JavaScript">
var i = 0;
var url_array = new Array();
url_array[0] = "http://fr.youtube.com/watch?v=IBj1aJBvjYE&feature=related";
url_array[1] = "http://fr.youtube.com/watch?v=qjSOz5w1GHI";
url_array[2] = "http://fr.youtube.com/watch?v=IifX6TbZuuQ";
url_array[3] = "http://www.friends-dating.co.uk/action_home+page.htm";
url_array[4] = "http://fr.youtube.com/watch?v=T4jdhGKekCo";
url_array[5] = "http://fr.youtube.com/watch?v=J7EY7wYhxow";

function changeURL(ms) {
document.frames['my_frame'].location.replace(url_array[i]);
i = (i+1)%url_array.length;
setTimeout("changeURL("+ms+")", ms);
}
</script>

</head>
<body style="margin:0px; overflow-y:hidden" onLoad="changeURL(5000);">
<iframe name="my_frame" width="100%" height="100%" border="0" frameborder="0"></iframe>
</body>
</html>

jscheuer1
12-21-2007, 03:36 PM
<html>
<head>
<title>URL Switcher</title>


<script type="text/javascript">
var i = 0;
var url_array = new Array();
url_array[0] = "http://fr.youtube.com/watch?v=IBj1aJBvjYE&feature=related";
url_array[1] = "http://fr.youtube.com/watch?v=qjSOz5w1GHI";
url_array[2] = "http://fr.youtube.com/watch?v=IifX6TbZuuQ";
url_array[3] = "http://www.friends-dating.co.uk/action_home+page.htm";
url_array[4] = "http://fr.youtube.com/watch?v=T4jdhGKekCo";
url_array[5] = "http://fr.youtube.com/watch?v=J7EY7wYhxow";

function changeURL(ms) {
window.frames['my_frame'].location.replace(url_array[i]);
i = (i+1)%url_array.length;
setTimeout("changeURL("+ms+")", ms);
}
</script>

</head>
<body style="margin:0px; overflow-y:hidden" onLoad="changeURL(5000);">
<iframe name="my_frame" width="100%" height="100%" border="0" frameborder="0"></iframe>
</body>
</html>

zoffmann
12-21-2007, 03:49 PM
thanks, I'll try your suggestion

zoffmann
12-21-2007, 04:10 PM
is it wrong to solve like this:


window.frames['my_frame'].location = url_array[i] ;

jscheuer1
12-21-2007, 04:21 PM
The only difference between:


window.frames['my_frame'].location = url_array[i];

and:


window.frames['my_frame'].location.replace(url_array[i]);

is that the first one adds to the history stack, while the second one does not. Since you are cycling through a ton of URL's, I wouldn't recommend using the the one that adds to the stack. Stick with:


window.frames['my_frame'].location.replace(url_array[i]);

zoffmann
12-21-2007, 04:36 PM
thank that was good suggestion