External javascript script Defer/Delay loaded example
代碼:
<html>
<head><title>test</title></head>
<body>
<script>
alert('Page load BEGIN');
</script>
<h1> page start </h1>
<script type="text/javascript">
function appendjs(jsfile)
{
var element = document.createElement("script");
element.src = jsfile;
document.body.appendChild(element);
}
function downloadJSAtOnload()
{
appendjs("1.js");
appendjs("2.js");
}
if (window.addEventListener)
window.addEventListener("load", downloadJSAtOnload, false);
else if (window.attachEvent)
window.attachEvent("onload", downloadJSAtOnload);
else
window.onload = downloadJSAtOnload;
</script>
<h1> page end </h1>
<script>
alert('Page load END');
</script>
</body>
</html>
@ 1.js
代碼:
alert('redner 1.js');
@ 2.js
代碼:
alert('redner 2.js');
________________
美術插畫設計案子報價系統 v0.1 Beta
爪哇禾雀
|