Results 1 to 6 of 6

Thread: script works in IE but not in Firefox, why

  1. #1
    Join Date
    Dec 2007
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question script works in IE but not in Firefox, why

    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.

    Code:
    <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>

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Code:
    <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>
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Dec 2007
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    thanks, I'll try your suggestion

  4. #4
    Join Date
    Dec 2007
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    is it wrong to solve like this:

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

  5. #5
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    The only difference between:

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

    Code:
    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:

    Code:
    window.frames['my_frame'].location.replace(url_array[i]);
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  6. #6
    Join Date
    Dec 2007
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    thank that was good suggestion

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •