window.onload 和 $(document).ready 区别 待续......
jquery 学习之一(js中window.onload与jquery中$(document.ready())的区别)
耳听为虚,眼见为实。通过下面的实例可查看两者的异同(注意:aa.jpg最好是一张大容量图片)
<script language='javascript'>(function () {var ie = !!(window.attachEvent && !window.opera);var wk = /webkit\/(\d+)/i.test(navigator.userAgent) && (RegExp.$1 < 525);var fn = [];var run = function () { for (var i = 0; i < fn.length; i++) fn[i](); };var d = document;d.ready = function (f) { if (!ie && !wk && d.addEventListener) return d.addEventListener('DOMContentLoaded', f, false); if (fn.push(f) > 1) return; if (ie) (function () { try { d.documentElement.doScroll('left'); run(); } catch (err) { setTimeout(arguments.callee, 0); } })(); else if (wk) var t = setInterval(function () { if (/^(loaded|complete)$/.test(d.readyState)) clearInterval(t), run(); }, 0);};})();</script>