•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 456,428 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,595 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 1295 | Replies: 2
![]() |
•
•
Join Date: Oct 2005
Location: Northampton UK
Posts: 1,142
Reputation:
Rep Power: 7
Solved Threads: 9
I have looked high and low for a very simple script that i can use to display on a page from 6 down to 1.
Basically it should start like this:
"this page will redirect in 6 seconds"
and end like this:
"this page will redirect in 0 seconds"
I know exactly the type of people on this forum and how clever you are so if you could please just help me out, I will be really really grateful.
Thanks
Basically it should start like this:
"this page will redirect in 6 seconds"
and end like this:
"this page will redirect in 0 seconds"
I know exactly the type of people on this forum and how clever you are so if you could please just help me out, I will be really really grateful.
Thanks
Normally such a thing is almost always done using a server side script (you know why), but since you have been nice in your conduct on Daniweb, I would try something out for you. 
How about something like:
Just let me know if it works for your cause. ;-)

How about something like:
javascript Syntax (Toggle Plain Text)
<!-- author: Sanjay aka ~s.o.s~ A simple redirection script which runs on the client side. --> <html> <head> <style> .myDiv { text-align: center; font: italic small-caps 900 14px arial } </style> <script> var count = 5; var timerHandle; var URL = "[url]http://www.yahoo.com[/url]"; var SITE_NAME = "Yahoo"; function startCountDown() { update(); timerHandle = setInterval("update()", 1000); } function update() { if(count <= 0) { clearInterval(timerHandle); document.getElementById('txt').innerHTML = 'Redirecting, please wait...'; window.location.assign(URL); /* You can also use the window.location.replace() function with the difference being you won't be able to hit the back button once the new page has been loaded. Use the function which suits your purpose */ } else { //you can also embed the entire message in a 'anchor' tag so that the user can decide not to //wait and click on the link to go to the site. document.getElementById('txt').innerHTML = 'You would be redirected to '+ SITE_NAME + ' in ' + count + ' seconds.'; --count; } } </script> </head> <body onload="javascript:startCountDown();"> <br /><br /><br /> <div class="myDiv" id="txt"></div> </body> </html>
Just let me know if it works for your cause. ;-)
I don't accept change. I don't deserve to live.
Happiness corrupts people.
Failing to value the lives of others cheapens your own.
Happiness corrupts people.
Failing to value the lives of others cheapens your own.
•
•
Join Date: Oct 2005
Location: Northampton UK
Posts: 1,142
Reputation:
Rep Power: 7
Solved Threads: 9
I have done the redirect in php.
All I wanted to know was how to just simply count from 6 down to 1 in javascript. It really is probably a 2 line code.
Thanks for your help
![]() |
•
•
•
•
•
•
•
•
DaniWeb JavaScript / DHTML / AJAX Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- simple script request [account balance calculation] (JavaScript / DHTML / AJAX)
- Simple script parser - how to ? (C++)
- [Need Help] shell scripting count data in files (Shell Scripting)
- Learning PHP but problem with script (PHP)
- A simple script to execute a command package (Shell Scripting)
- derive full name of user and grep search count (Shell Scripting)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: Random text and images
- Next Thread: help on passing variable to a function?



Linear Mode