sxyloverboy 0 Report post Posted December 6, 2005 ok here is a question:how would i do something that says you will be redirected in 15 seconds and then changes the number till the redirection takes place. this is planned for a custom 404 error page. im not just asking for the countdown but also how to redirect at all. thankfull for any help :PLucas Share this post Link to post Share on other sites
rvalkass 5 Report post Posted December 6, 2005 This should do something similar to what you need. Simply cut and paste it and change the few settings.http://javascriptkit.com/script/script2/countredirect.shtml Share this post Link to post Share on other sites
sxyloverboy 0 Report post Posted December 6, 2005 yeah thats pretty much what i mean. but i dont really like the form thing that shows the number? is there maybe a way to get a number that looks like its in the text? Share this post Link to post Share on other sites
switch 0 Report post Posted December 6, 2005 well, there's a bare-bones html way of redirecting, but you can't display the seconds remaining or anything with it. what you basically do is add this in between the <HEAD> tags. <meta http-equiv="REFRESH" content="time; URL=your.url"> where time is an integer representing number of seconds until redirect, and your.url is the url that you wish to redirect to.also html-redirect.html notes that It is customary to include a direct link to the page that will be switched to automatically in case you get an older browser that doesn't support the feature or the user doesn't want to wait.i know that there is a way of using a java applet to countdown to 0 and then redirect, but you probably wouldn't want an applet on a 404 error page javascript is probably the way to go for that (although it can be easily disabled- so that's another consideration).all in all, HTML redirection is probably the most compatible way to do it, and, although it can't do anything really flashy, it gets the job done no problems.all the best. Share this post Link to post Share on other sites
peroim 0 Report post Posted July 11, 2006 (edited) if you really want it in HTML and java script:Insert this in the HEAD of you page: <script language='JavaScript'>var time = 15; //How long (in seconds) to countdownvar page = "yourpage.htm"; //The page to redirect tofunction countDown(){time--;gett("container").innerHTML = time;if(time == -1){window.location = page;}}function gett(id){if(document.getElementById) return document.getElementById(id);if(document.all) return document.all.id;if(document.layers) return document.layers.id;if(window.opera) return window.opera.id;}function init(){if(gett('container')){setInterval(countDown, 1000);gett("container").innerHTML = time;}else{setTimeout(init, 50);}}document.onload = init();</SCRIPT> And this in the body of the page (where you want the countdown to appear):<span id='container'></span> Edited July 11, 2006 by peroim (see edit history) Share this post Link to post Share on other sites
swift29 0 Report post Posted June 16, 2010 hi im new here but i would just like to say it took me ages to find this and yours was the best one so thanks, but how do you change the colour of the countdown Share this post Link to post Share on other sites
iGuest 3 Report post Posted April 6, 2011 if you really want it in HTML and java script:Insert this in the HEAD of you page: <script language='JavaScript'>var time = 15; //How long (in seconds) to countdownvar page = "yourpage.htm"; //The page to redirect tofunction countDown(){time--;gett("container").innerHTML = time;if(time == -1){window.location = page;}}function gett(id){if(document.getElementById) return document.getElementById(id);if(document.all) return document.all.id;if(document.layers) return document.layers.id;if(window.opera) return window.opera.id;}function init(){if(gett('container')){setInterval(countDown, 1000);gett("container").innerHTML = time;}else{setTimeout(init, 50);}}document.onload = init();</SCRIPT> And this in the body of the page (where you want the countdown to appear):<span id='container'></span> Awesome, this is exactly what I needed :) much thanks Share this post Link to post Share on other sites