Results 1 to 8 of 8

Thread: Refresh page Script (mod)

  1. #1
    Join Date
    Mar 2007
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Refresh page Script (mod)

    Script Title: Refresh page Script

    Script URL: http://www.dynamicdrive.com/dynamicindex6/refresh.htm

    Is there a way to make this script go to another page rather than refreshing the current page?

  2. #2
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    Switch the line:
    Code:
    window.location.reload()
    with
    Code:
    window.open("newpage.htm","newWindow","width=500,height=500,left=5,top=30");
    The width/height/left/top are just parameters to adjust the window settings.

    //EDIT: Read post below . I didn't know that location.replace() was a function, so use Twey's example. Sorry folks.
    Last edited by mburt; 06-08-2007 at 01:52 PM.
    - Mike

  3. #3
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    What? That will (attempt to, and usually fail to due to popup blockers) open a new window. To navigate to another page, you would use:
    Code:
    location.replace("newpage.html");
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  4. #4
    Join Date
    Mar 2007
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Could you highlight each part of the code where I need to place that?

    Thanks.

  5. #5
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    Code:
    <script language="JavaScript">
    
    //Refresh page script- By Brett Taylor (glutnix@yahoo.com.au)
    //Modified by Dynamic Drive for NS4, NS6+
    //Visit http://www.dynamicdrive.com for this script
    
    //configure refresh interval (in seconds)
    var countDownInterval=60;
    //configure width of displayed text, in px (applicable only in NS4)
    var c_reloadwidth=200
    
    </script>
    
    
    <ilayer id="c_reload" width=&{c_reloadwidth}; ><layer id="c_reload2" width=&{c_reloadwidth}; left=0 top=0></layer></ilayer>
    
    <script>
    
    var countDownTime=countDownInterval+1;
    function countDown(){
    countDownTime--;
    if (countDownTime <=0){
    countDownTime=countDownInterval;
    clearTimeout(counter)
    window.location.replace("newpage.htm")
    return
    }
    if (document.all) //if IE 4+
    document.all.countDownText.innerText = countDownTime+" ";
    else if (document.getElementById) //else if NS6+
    document.getElementById("countDownText").innerHTML=countDownTime+" "
    else if (document.layers){ //CHANGE TEXT BELOW TO YOUR OWN
    document.c_reload.document.c_reload2.document.write('Next <a href="javascript:window.location.replace('newpage.htm')">refresh</a> in <b id="countDownText">'+countDownTime+' </b> seconds')
    document.c_reload.document.c_reload2.document.close()
    }
    counter=setTimeout("countDown()", 1000);
    }
    
    function startit(){
    if (document.all||document.getElementById) //CHANGE TEXT BELOW TO YOUR OWN
    document.write('Next <a href="javascript:window.location.reload()">refresh</a> in <b id="countDownText">'+countDownTime+' </b> seconds')
    countDown()
    }
    
    if (document.all||document.getElementById)
    startit()
    else
    window.onload=startit
    
    </script>
    - Mike

  6. #6
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    Code:
    <script language="JavaScript">
    
    //Refresh page script- By Brett Taylor (glutnix@yahoo.com.au)
    //Modified by Dynamic Drive for NS4, NS6+
    //Visit http://www.dynamicdrive.com for this script
    
    //configure refresh interval (in seconds)
    var countDownInterval=60;
    //configure width of displayed text, in px (applicable only in NS4)
    var c_reloadwidth=200
    
    </script>
    
    
    <ilayer id="c_reload" width=&{c_reloadwidth}; ><layer id="c_reload2" width=&{c_reloadwidth}; left=0 top=0></layer></ilayer>
    
    <script>
    
    var countDownTime=countDownInterval+1;
    function countDown(){
    countDownTime--;
    if (countDownTime <=0){
    countDownTime=countDownInterval;
    clearTimeout(counter)
    window.location.replace('newpage.html');
    return
    }
    if (document.all) //if IE 4+
    document.all.countDownText.innerText = countDownTime+" ";
    else if (document.getElementById) //else if NS6+
    document.getElementById("countDownText").innerHTML=countDownTime+" "
    else if (document.layers){ //CHANGE TEXT BELOW TO YOUR OWN
    document.c_reload.document.c_reload2.document.write('Next <a href="javascript:window.location.replace("newpage.html");">refresh</a> in <b id="countDownText">'+countDownTime+' </b> seconds')
    document.c_reload.document.c_reload2.document.close()
    }
    counter=setTimeout("countDown()", 1000);
    }
    
    function startit(){
    if (document.all||document.getElementById) //CHANGE TEXT BELOW TO YOUR OWN
    document.write('Next <a href="javascript:window.location.replace("newpage.html");">refresh</a> in <b id="countDownText">'+countDownTime+' </b> seconds')
    countDown()
    }
    
    if (document.all||document.getElementById)
    startit()
    else
    window.onload=startit
    
    </script>
    The red highlighted part is the only one you really have to change; however, if you want the link in the phrase

    Next refresh in 57 seconds
    to go to the new page, then make the changes with the highlighted "blue" parts.

    Hope this helps.

    //EDIT: sorry Mike, cross posted.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  7. #7
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Er, using document.write() once the page has loaded will kind of break the page.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  8. #8
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    I thought it was odd as well, but that's the way the script is on DD.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

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
  •