Jump to content

60 Timer Needed


Teiko1985

Recommended Posts

Can anyone help me with a 60 second timer for my website. I want to display the following text to my customers at the top of the page: "You will be automatically redirected to homepage in [timer]"

 

In my header I have the following code: <meta http-equiv="refresh" content="61;url=home.php">

Link to comment
Share on other sites

No one wants to wait 60 seconds for a page refresh.  Most people don't even view a single web page for 60 seconds.  But, if you want one, here is a javascript one.

 

<div style="display:none;" id="strclock">Clock Here!</div>
<div id="clock">To Update Click the button below!</div>
<script type="text/javascript">
var hour = 0;
var min = 1;
var sec = 0;

function checkTime() {
var time = document.getElementById('strclock').innerHTML;
if(time == '00:00:00') {
window.location = 'http://google.com';
}
}


function countdown() {
if(sec <= 0 && min > 0) {
  sec = 59;
  min -= 1;
}
else if(min <= 0 && sec <= 0) {
  min = 0;
  sec = 0;
}
else {
  sec -= 1;
}

if(min <= 0 && hour > 0) {
  min = 59;
  hour -= 1;
}

var pat = /^[0-9]{1}$/;
secs = (pat.test(sec) == true) ? '0'+sec : sec;
mins = (pat.test(min) == true) ? '0'+min : min;
hours = (pat.test(hour) == true) ? '0'+hour : hour;

document.getElementById('strclock').innerHTML = hours+":"+mins+":"+secs;
if(min >= 1) {	
document.getElementById('clock').innerHTML = min+1+' minutes until timer runs out!';
}
else {
document.getElementById('clock').innerHTML = sec+' seconds until timer runs out!';
}

checkTime();
setTimeout("countdown()",1000);
}
countdown();
</script>

Link to comment
Share on other sites

take a look at my site: mysexywear.com its only because some people based on the lap top screen cannot see my enter site button under my slider so I am in the process of moving everything up but as a safety I redirect them automatically to my homepage.

 

Thanks for the code. I will try it out now!

 

How do I keep the timer in line without  dropping down to a second row with the div

Link to comment
Share on other sites

Firstly: Your question is in NO WAY related to PHP. So it's in the wrong forum.

Secondly: We are not here to write code for people.

Thirdly: Statements like "code doesn't work" don't help us help you.

 

I'm not sure your ready for this place.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.