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?
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?
Switch the line:
withCode:window.location.reload()
The width/height/left/top are just parameters to adjust the window settings.Code:window.open("newpage.htm","newWindow","width=500,height=500,left=5,top=30");
//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
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!
Could you highlight each part of the code where I need to place that?
Thanks.
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
The red highlighted part is the only one you really have to change; however, if you want the link in the phraseCode:<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>
to go to the new page, then make the changes with the highlighted "blue" parts.Next refresh in 57 seconds
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
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!
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