<!DOCTYPE html>
<html>
<head>
<title></title>
<script type="text/javascript" src="js/test.js"></script>
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="format-detection" content="telephone=no" />
<script type="text/javascript">
alert("head");
</script
</head>
<body onload="alert(document.readyState)">
</body>
<script type="text/javascript">
alert("footer");
</script
</html>
关键技术讲解:
<body onload="alert(document.readyState)">
onload 事件会在页面或图像加载完成后立即发生。
引用顺序:
页面上的JavaScript按引用和编写的顺序从上到下依次执行(在页面加载以前);
onload在页面加载之后执行;
执行结果:head——》footer——》complete
本文介绍了HTML中onload事件的触发时机及其执行顺序。详细解释了onload事件如何在页面加载完成后触发,并通过示例代码展示了不同位置的JavaScript代码执行顺序。
922

被折叠的 条评论
为什么被折叠?



