我得到一个json {'info':'注册成功,5秒后跳转......'} 我想问,怎么让它倒计时显示 5 4 3 2 1 我现在只会 success:function(data){
setTimeout("location_url()",5000);
}
function location_url(){
window.location.href="index.aspx";
}
怎么让它显示:5 4 3 2 1呢?
setTimeout("location_url()",5000);
}
function location_url(){
window.location.href="index.aspx";
}
怎么让它显示:5 4 3 2 1呢?
<script type="text/javascript">
var json = {'info':'注册成功,5秒后跳转......'};
var number = json["info"].match(/\d+/);
var Timer;
function ResponseRedirect(){
document.getElementById("id").innerHTML=number;
number--;
if(number==0){
clearTimeout(Timer);
window.location.href="http://www.baidu.com";
}
else
Timer = setTimeout(ResponseRedirect,"1000");
}
ResponseRedirect();
</script>
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(function() {
var decreasement = function() {
if (count > 0) {
$("#msg").html("<h1>" + count + "</h1>");
count --;
setTimeout(decreasement, 1000);
}
else {
// 跳转
}
};
decreasement();
}); </script>
</head>
<body>
<div id="msg"></div>
</body>
</html>