达尔之心
2015-10-13 20:24
放在头文件一点用都没有,移动到body里就正常了,为什么呢?
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>domready</title>
<script src="../domReady.js"></script>
<script>
var d = document;
var msgBox = d.getElementById("showMsg");
var imgs = d.getElementsByTagName("img");
var time1 = null, time2 = null;
myReady(function(){
msgBox.innerHTML += "dom已加载!<br>";
time1 = new Date().getTime();
msgBox.innerHTML +="时间截:" + time1 + "<br>";
});
window.onload = function(){
msgBox.innerHTML += "onload已加载!<br>";
time2 = new Date().getTime();
msgBox.innerHTML += "时间戳:" + time2 + "<br>";
msgBox.innerHTML += "时间截:" + (time2 - time1) + "ms<br>";
}
</script>
</head>
<body>
<div id="showMsg"></div>
<div>
<img src="1.jpg"/>
<img src="2.jpg"/>
<img src="3.jpg"/>
<img src="4.jpg"/>
<img src="5.jpg"/>
<img src="6.jpg"/>
</div>
</body>
</html>
同问这个问题
加载完成后再回调函数?
是不是给后面的引入覆盖了 还是引入写错了
DOM探索之基础详解篇
98374 学习 · 238 问题
相似问题