![](/img/trans.png)
[英]Javascript function works in chrome and safari but breaks in Firefox
[英]Javascript function fails to execute in safari, firefox and chrome
<script>
function moveon() {
//display a modal dialog to ask the user question
var answer = confirm("Ready to move on? ");
// If they clicked the "ok" button, make the browser load a new page.
if (answer)
window.location = "http://google.com";
}
//run the function defined above 1 minute (60,000 milliseconds) from now
setTimeout(moveon, 60000);
</script>
我想知道为什么这个代码片段无法在我的html文件中执行,即使它直接来自javascript权威指南。
我是Mac用户,所以还没有机会在PC上进行测试。
尝试:
window.location.href = "http://google.com";
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.