Skip to content

Instantly share code, notes, and snippets.

@markyun
Created July 3, 2013 06:23
Show Gist options
  • Save markyun/5915830 to your computer and use it in GitHub Desktop.
Save markyun/5915830 to your computer and use it in GitHub Desktop.
<!--js实现定义倒计时后自动跳转页面-->
<script type="text/javascript">
// <span style="color: red;" id="totalSecond">5</span>秒
var second = document.getElementById('totalSecond').textContent;
if (navigator.appName.indexOf("Explorer") > -1)
{
second = document.getElementById('totalSecond').innerText;
} else
{
second = document.getElementById('totalSecond').textContent;
}
setInterval("redirect()", 1000);
function redirect()
{
if (second < 0)
{
// <!--定义倒计时后跳转页面-->
location.href = 'http://localhost:8080/';
} else
{
if (navigator.appName.indexOf("Explorer") > -1)
{
document.getElementById('totalSecond').innerText = second--;
} else
{
document.getElementById('totalSecond').textContent = second--;
}
}
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment