资料
表格
制度
合同
管理
职场
经营
创业
范文
总结
计划
作文
文章
美文
词句
教程
模板
图片
字体
图标
办公
人事
财务
生产
管理资源吧首页
>>>
教程
>>>
编程
>>>
JavaScript教程
>>>
用javascript实现jquery的document.ready功能的实现代码
实现jQuery的document.ready功能
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>document.ready</title> <img src="/_New/_cj/myeditor/sysimage/space.gif" class="ewebeditor__script" _ewebeditor_fake_tag="script" _ewebeditor_fake_value="%3Cscript%20type%3D%22text%2Fjavascript%22%3E%20%0D%0A(function%20()%20%7B%20%0D%0Avar%20ie%20%3D%20!!(window.attachEvent%20%26%26%20!window.opera)%3B%20%0D%0Avar%20wk%20%3D%20%2Fwebkit%5C%2F(%5Cd%2B)%2Fi.test(navigator.userAgent)%20%26%26%20(RegExp.%241%20%3C%20525)%3B%20%0D%0Avar%20fn%20%3D%20%5B%5D%3B%20%0D%0Avar%20run%20%3D%20function%20()%20%7B%20for%20(var%20i%20%3D%200%3B%20i%20%3C%20fn.length%3B%20i%2B%2B)%20fn%5Bi%5D()%3B%20%7D%3B%20%0D%0Avar%20d%20%3D%20document%3B%20%0D%0Ad.ready%20%3D%20function%20(f)%20%7B%20%0D%0Aif%20(!ie%20%26%26%20!wk%20%26%26%20d.addEventListener)%20%0D%0Areturn%20d.addEventListener('DOMContentLoaded'%2C%20f%2C%20false)%3B%20%0D%0Aif%20(fn.push(f)%20%3E%201)%20return%3B%20%0D%0Aif%20(ie)%20%0D%0A(function%20()%20%7B%20%0D%0Atry%20%7B%20d.documentElement.doScroll('left')%3B%20run()%3B%20%7D%20%0D%0Acatch%20(err)%20%7B%20setTimeout(arguments.callee%2C%200)%3B%20%7D%20%0D%0A%7D)()%3B%20%0D%0Aelse%20if%20(wk)%20%0D%0Avar%20t%20%3D%20setInterval(function%20()%20%7B%20%0D%0Aif%20(%2F%5E(loaded%7Ccomplete)%24%2F.test(d.readyState))%20%0D%0AclearInterval(t)%2C%20run()%3B%20%0D%0A%7D%2C%200)%3B%20%0D%0A%7D%3B%20%0D%0A%7D)()%3B%20%0D%0Adocument.ready(function()%7B%20%0D%0Adocument.getElementById('test').innerHTML%20%3D%20'document.ready%20test!'%3B%20%2F%2F%E6%89%BE%E5%88%B0%20%0D%0A%7D)%3B%20%0D%0Aalert(document.getElementById('test'))%3B%20%2F%2Fnull%20%E6%B2%A1%E6%89%BE%E5%88%B0%20%0D%0A%3C%2Fscript%3E"> </head> <body> <div id="test"></div> </body> </html>
[Ctrl+A 全选 注:
如需引入外部Js需刷新才能执行
]
教程首页
更多教程