gpt4 book ai didi

javascript - chrome 56 和 chrome 60 之间的加载行为差异问题

转载 作者:行者123 更新时间:2023-11-30 21:18:03 26 4
gpt4 key购买 nike

当我尝试在 chrome 60 中测试在 chrome 56 中工作的应用程序屏幕时,我遇到了一些问题,我可以用这个示例 html 演示原因:

<!DOCTYPE html>
<html>
<head>
<script>

function windowOnload() {
alert("window onload called");
}

function bodyOnload() {
alert("body onload called");
}
window.onload = windowOnload;
</script>
</head>
<body onload="bodyOnload()">

<h1>on load test</h1>



</body>
</html>

在 chrome 56 中 windowOnload 和 bodyOnload 都被调用,在 chrome 60 中只调用 bodyOnload。我修复了有问题的页面,但正在寻找更改原因的一些解释,但在 Chrome 发行说明中找不到任何内容。

最佳答案

这似乎是旧版本中的错误,已在较新版本中修复。这是 bug report .

这是在 body 的 HTML 规范中指定的元素:

The onblur, onerror, onfocus, onload, onresize, and onscroll event handlers of the Window object, exposed on the body element, replace the generic event handlers with the same names normally supported by HTML elements.

所以当<body onload="bodyOnload()">元素被解析,它执行等价于:

window.onload = function() {
bodyOnload();
};

它取代了 window.onload在您的 Javascript 中设置的属性。

关于javascript - chrome 56 和 chrome 60 之间的加载行为差异问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45471610/

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