何谓domReady
2016-05-04 01:13
549 查看
原文详细介绍:http://www.cnblogs.com/rubylouvre/p/4536334.html
关键代码:
在标准浏览器下,匿名函数会一只try-catch下去。
关于doScroll的详细介绍:https://msdn.microsoft.com/en-us/library/ms536414(v=vs.85).aspx
大概意思:IE专用,IE11以下,Simulates a click on a scroll bar component ,模拟一个滚动条组件上的点击。
===============================================================================
同理,HTML转换DOM过程,可以根据document.body来判断,简单测试了下可以通过,但是在html内元素多的时候,可能会出现bug。
关键代码:
function IEContentLoaded (w, fn) { var d = w.document, done = false, // 只执行一次用户的回调函数init() init = function () { if (!done) { done = true; fn(); } }; (function () { try { // DOM树未创建完之前调用doScroll会抛出错误 d.documentElement.doScroll('left'); } catch (e) { //延迟再试一次~ setTimeout(arguments.callee, 50); return; } // 没有错误就表示DOM树创建完毕,然后立马执行用户回调 init(); })(); //监听document的加载状态 d.onreadystatechange = function() { // 如果用户是在domReady之后绑定的函数,就立马执行 if (d.readyState == 'complete') { d.onreadystatechange = null; init(); } }; }
在标准浏览器下,匿名函数会一只try-catch下去。
关于doScroll的详细介绍:https://msdn.microsoft.com/en-us/library/ms536414(v=vs.85).aspx
大概意思:IE专用,IE11以下,Simulates a click on a scroll bar component ,模拟一个滚动条组件上的点击。
===============================================================================
同理,HTML转换DOM过程,可以根据document.body来判断,简单测试了下可以通过,但是在html内元素多的时候,可能会出现bug。
function ConLoaded(w,fn){ var d = w.document, done = false, // 只执行一次用户的回调函数init() init = function () { if (!done) { done = true; fn(); } }; (function () { if( d.body == null ){ setTimeout(arguments.callee, 50); return false; }; init(); })(); };
相关文章推荐
- 关系数据模型和范式
- 网站开发感性认识(学习思路)
- 字符串操作函数模拟实现大全
- SSH(一)~——Struts实现简单登录(附源码)
- 工厂模式(Factory)
- kaggle实例学习-Titanic(1)
- 在华为海思HI3518上移植和运行QT4.8.6 undefined reference to accept4
- spring4.1.1 jar包说明
- 漫威史上最黑暗 美国队长3英雄内战导火索 雷神索尔去哪了?
- 关于本人树莓派捣鼓过程中的一些记录
- sysctl
- DEPRECATED: Use of this script to execute hdfs command is deprecated. Instead use the hdfs command
- Android OpenGL10 纹理 <4>
- lightoj1282 - Leading and Trailing(水题)
- SpringMVC Controller介绍
- linux目录结构详细介绍
- [CareerCup] 18.3 Randomly Generate Integers 随机生成数字
- C++11 多线程
- 前后端数据交互方法
- ruby on rails爬坑(五):配置邮件服务器