gpt4 book ai didi

Firefox 上的 Javascript 在 onchange 赋值时意外停止执行

转载 作者:行者123 更新时间:2023-11-28 01:55:41 25 4
gpt4 key购买 nike

以下 JavaScript 代码片段在 Google Chrome 上完美运行,但在 Firefox 上出现第二个警报之前不会继续:

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:

function foo() {
// some other code for function foo
break;
// the rest of the code
}

然而,Firefox 或 Chrome 的开发者工具控制台没有报告任何错误,这让我沮丧了好几天。

最佳答案

在循环或 switch 语句中不使用任何 break 语句时,请将其删除。

关于Firefox 上的 Javascript 在 onchange 赋值时意外停止执行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19176090/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com