我是JavaScript新手,我想知道如何实现重定向功能,在倒计时完成后将用户重定向到主页。这是一个正在建设/发射的网站,我真的希望它自己重定向,而不是他们刷新它!
我的代码:
<script language="javascript" type="text/javascript">
var redirect="my website"
jQuery(document).ready(function() {
$('#countdown').countDown({
targetDate: {
'day': <?php echo $row['day'] ?>,
'month': <?php echo $row['month'] ?>,
'year': <?php echo $row['year'] ?>,
'hour': <?php echo $row['hour'] ?>,
'min': <?php echo $row['min'] ?>,
'sec': <?php echo $row['sec'] ?>
}
});
});
</script>
谢谢!
答案 0 :(得分:2)
如果您查看文档,则会有一个onComplete
回调。这应该有用。
<script language="javascript" type="text/javascript">
var redirect="my website"
jQuery(document).ready(function() {
$('#countdown').countDown({
targetDate: {
'day': <?php echo $row['day'] ?>,
'month': <?php echo $row['month'] ?>,
'year': <?php echo $row['year'] ?>,
'hour': <?php echo $row['hour'] ?>,
'min': <?php echo $row['min'] ?>,
'sec': <?php echo $row['sec'] ?>
},
onComplete: function(){
window.location.replace(redirect);
}
});
});
</script>
http://www.littlewebthings.com/projects/countdown/example.php?e=on_complete