我是新来的JS,我不知道什么时候完成的功能执行。onload与脚本在body结尾的区别?
实例A:
<html>
<head>
<title>A</title>
<script src="myScript.js"></script>
</head>
<body onload="myFunction()">
[Content here...]
</body>
</html>
例B:
<html>
<head>
<title>B</title>
<script src="myScript.js"></script>
</head>
<body>
[Content here...]
<script>
myFunction();
</script>
</body>
</html>
从我到目前为止当解析器达到其执行功能来读取。这不会让例子A和B一样吗?当在B中调用myFunction()时,屏幕上是否显示页面的所有内容(例如带文本的表格)?
onload事件将触发一次整个网页,包括图像,音频/视频被加载,而身体标记结束之前,就像DOMContentLoaded事件.. – Rayon