Skip to content

Instantly share code, notes, and snippets.

@sivaprabug
Created May 4, 2016 13:45
Show Gist options
  • Select an option

  • Save sivaprabug/db50d1f0da1d0dc8c9d7ea4b4d96f2d3 to your computer and use it in GitHub Desktop.

Select an option

Save sivaprabug/db50d1f0da1d0dc8c9d7ea4b4d96f2d3 to your computer and use it in GitHub Desktop.
Javascript countdown redirect to another page
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<form name="redirect">
<center>
<font face="Arial"><b>You will be redirected to the script in<br><br>
<form>
<input type="text" size="3" name="redirect2">
</form>
seconds</b></font>
</center>
<script>
var targetURL = "http://10.0.136.11/sivaprabug/js.html"
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>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment