[英]Javascript on Firefox stops execution unexpectedly on an onchange assignment
The following javascript code snippets runs perfectly on Google Chrome but doesn't continue before the second alert on Firefox: 以下javascript代码段可在Google Chrome上完美运行,但在Firefox上出现第二个警报之前不会继续:
init.js
: init.js
:
function __init__() {
alert("welcome!");
document.getElementById("myselector").onchange = foo;
alert("must go here");
// some other initialization code goes here
alert("must end here");
}
window.onload = __init__;
foo.js
: foo.js
:
function foo() {
// some other code for function foo
break;
// the rest of the code
}
There were no errors reported by the Firefox or Chrome's Developer Tool Console however, keeping me frustrated for days. 但是,Firefox或Chrome的开发者工具控制台未报告任何错误,这让我沮丧了好几天。
在循环或switch
语句中不使用任何break
语句时,请将其删除。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.