Results 1 to 2 of 2

Thread: Javascript: Wait until page loads instead of timer.

  1. #1
    Registered User
    Join Date
    Feb 2012
    Posts
    1
    Thanks
    0
    Thanked
    0 times in 0 posts

    Javascript: Wait until page loads instead of timer.

    Ive got the following script in my page, it switches page every 10 seconds which works well however I would prefer it to wait until the page it load up is completed before moving onto the next link because some people who use it are finding the pages aren't loading completely before it switches. Anyone know if its a simple change from 10000 to a different variable? Im just drawing a blank.

    <script type="text/javascript">

    var win = null;
    var i = 0;
    var links = [
    <!--Link 1-->
    "url",
    <!--Link 2-->
    "url",
    <!--Link 3-->
    "url",
    <!--Link 4-->
    "url"
    ];


    function cranking(idx) {
    if(!win){
    win = window.open();
    };

    win.location.href = (links[idx]);

    if(idx < (links.length - 1)) {
    idx++;
    setTimeout('cranking(' + idx + ')', 10000);
    //or setTimeout('cranking(idx)', 10000);
    };
    };
    </script>

  2. #2
    blueball
    Guest

    Re: Javascript: Wait until page loads instead of timer.

    Could you play with this code to help? ie check to see if page has loaded before running script

    http://stackoverflow.com/questions/9...ie-7-firefox-3

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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