有这样一个页面 自动跳转其他页面
<a href="https://www.baidu.com"><span id="begin">3</span>秒后跳转</a>
<script>
var t = 3;
var timer = setInterval(time, 1000);
var spans = document.getElementById("begin");
function time() {
t--;
spans.innerHTML = '<span>' + t + '</span>';
if(t == 0) {
clearInterval(timer);
return window.location.href = 'https://www.baidu.com';
}
console.log(t);
}
</script>
不用return false,还有禁用浏览器默认事件的情况下怎么禁止网页自动跳转
这个代码不就是想让页面自动跳吗? 既然不想跳转,为什么要写。。。