Popup Redirection? |
Popup Redirection? |
starvinmarvin14 |
Mar 23 2009, 12:29 AM
Post
#1
|
Group: Members Posts: 4 Joined: 23-March 09 Member No.: 8,136 |
Hey, Ignore the title.
I have this code for a redirect: <!doctype 3.2 final//en -//w3c//dtd public html> <center><br/> <p><form name="redirect"> <center> <font face="Arial"><b>You will be redirected to www.domain.com<br/><br/> <form> <input name="redirect2" size="3" type="text"/> </form> seconds</b></font> </center> <script> <!-- //change below target URL to your own var targetURL="ENTER HERE" //change the second to start counting down from var countdownfrom=10 var currentsecond=document.redirect.redirect2.value=countdownfrom+1 function countredirect(){ if (currentsecond!=1){ currentsecond-=1 document.redirect.redirect2.value=currentsecond } else{ window.location=targetURL return } setTimeout("countredirect()",1000) } countredirect() //--> </script> </form></p></center> </!doctype> Is there any way I can add a cancel button to that? You can see it here: http://gaminglagoon4free.blogspot.com/ This post has been edited by starvinmarvin14: Mar 23 2009, 01:00 AM |
Darin McGrew |
Mar 23 2009, 01:24 AM
Post
#2
|
WDG Member Group: Root Admin Posts: 8,365 Joined: 4-August 06 From: Mountain View, CA Member No.: 3 |
QUOTE <!doctype 3.2 final//en -//w3c//dtd public html> This is broken, and will trigger quirks mode in modern browsers. Please see the FAQ entry What is a DOCTYPE? Which one do I use?Also, this is about JavaScript, so I've moved it to the Client-side Scripting forum. |
Christian J |
Mar 23 2009, 05:03 AM
Post
#3
|
. Group: WDG Moderators Posts: 9,661 Joined: 10-August 06 Member No.: 7 |
You can use clearTimeout to stop a timer, as shown on e.g. http://www.w3schools.com/js/js_timing.asp
|
starvinmarvin14 |
Mar 23 2009, 10:42 AM
Post
#4
|
Group: Members Posts: 4 Joined: 23-March 09 Member No.: 8,136 |
Sorry guys, I'm kind of a really big nub. I don't know how to incorporate the clearTimout() as a button because every time I try it doesn't work. Is it because there is no variable for the setTimeout() ?
Also, how do I fix: <!doctype 3.2 final//en -//w3c//dtd public html> Thanks! |
Christian J |
Mar 23 2009, 10:47 AM
Post
#5
|
. Group: WDG Moderators Posts: 9,661 Joined: 10-August 06 Member No.: 7 |
I don't know how to incorporate the clearTimout() as a button because every time I try it doesn't work. Is it because there is no variable for the setTimeout() ? I think so. QUOTE Also, how do I fix: <!doctype 3.2 final//en -//w3c//dtd public html> Here are a few you can use: http://www.htmlhelp.com/tools/validator/doctype.html but if you pick the first one you'll get errors in a validator for using presentational HTML elements and attributes. BTW this is unrelated to the redirect issue. |
starvinmarvin14 |
Mar 23 2009, 11:09 AM
Post
#6
|
Group: Members Posts: 4 Joined: 23-March 09 Member No.: 8,136 |
AHH! I can't get it to work.
This is what I have now: <!doctype transitional//en 4.01 -//w3c//dtd public html http://www.w3.org/tr/html4/loose.dtd> <center><br/> <p><form name="redirect"> <center> <font face="Arial"><b>You will be redirected to www.domain.com<br/><br/> <form> <input name="redirect2" size="3" type="text"/> </form> seconds</b></font> </center> <script> <!-- var targetURL="ENTER HERE" var countdownfrom=10 var currentsecond=document.redirect.redirect2.value=countdownfrom+1 function countredirect(){ if (currentsecond!=1){ currentsecond-=1 document.redirect.redirect2.value=currentsecond } else{ window.location=targetURL return } var r = setTimeout("countredirect()",1000) setTimeout® } countredirect() function stopCount() { clearTimeout®; } </script> <input onclick="stopCount()" value="Stop count!" type="button"/> </form></p></center> </!doctype> Can someone please clarify this and maybe correct my mistakes in the code? Thanks. BTW the ® symbols are actually ( r ) without the spaces. This post has been edited by starvinmarvin14: Mar 23 2009, 11:10 AM |
Darin McGrew |
Mar 23 2009, 01:33 PM
Post
#7
|
WDG Member Group: Root Admin Posts: 8,365 Joined: 4-August 06 From: Mountain View, CA Member No.: 3 |
QUOTE <!doctype transitional//en 4.01 -//w3c//dtd Do not change the doctype. Just copy-paste it. Here is the correct HTML 4.01 Transitional doctype:public html http://www.w3.org/tr/html4/loose.dtd> QUOTE <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> |
Lo-Fi Version | Time is now: 28th April 2024 - 03:11 AM |