PDA

View Full Version : How can i remove this?



sphinx1994
Sep 9th, 2009, 07:35 PM
Hello,

I'm currently using this code:

I want it so that there isnt a box around the countdown, and the countdown is the same text as "you will be redirected in"

here is it in action: http://www.playelite.org/redirect.html


<form name="redirect">
<center>
<font face="Arial"><b>You will be redirected in:
<form>
<input type="text" size="3" border="0" name="redirect2">
</form>
seconds</b></font>
</center>

<script>
<!--
var targetURL="http://google.com"
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>

Thanks

Fumigator
Sep 9th, 2009, 08:01 PM
You'll want to change the script to not use an <input> tag then. Use a <span> tag and change the innerHTML each time the timer counts down.

Incidentally there is a fantastic jQuery plug-in that handles this kind of thing fabulously:

http://keith-wood.name/countdown.html

It is a bit of a learning curve to get a handle on jQuery but it's worth it.

Philip M
Sep 9th, 2009, 08:13 PM
Here you are:-



<span id = "message" style="color:red; font-size:14pt; font-family:arial,verdana,sans-serif"></span>

<script type = "text/javascript">

var targetURL="http://google.com";
var countdownfrom = 10;
var currentsecond = countdownfrom +1;
function countredirect() {
if (currentsecond !=1 ){
currentsecond -=1;
var mess = "You will be redirected in " + currentsecond + " seconds";
document.getElementById("message").innerHTML = mess;
}
else{
window.location=targetURL;
}
setTimeout("countredirect()",1000);
}

countredirect();

</script>

The <!-- and //--> comment (hiding) tags have not been necessary since IE3.
Also, make sure to always put semicolons in your code at the end of each statement, to avoid potential subtle problems.

Fumigator - Why use jQuery for something as simple as this?



"When I was a kid I used to pray every night for a new bike. Then I realised that The Lord doesn't work that way, so I stole one and asked him to forgive me."