gpt4 book ai didi

javascript - IE DOMContentLoaded documentElement.doScroll

转载 作者:数据小太阳 更新时间:2023-10-29 04:44:43 25 4
gpt4 key购买 nike

DOMContentLoaded trick for IE by Diego Perini有什么原因吗?仅当窗口不在流行的 JS 库中的 iframe 中时才实现?

jQuery:

//If IE and not a frame continually check to see if the document is ready

var toplevel = false;

try {
toplevel = window.frameElement == null;
} catch(e) {}

if ( document.documentElement.doScroll && toplevel ) {
doScrollCheck();
}

原型(prototype):

document.observe('readystatechange', checkReadyState);
if (window == top)
timer = pollDoScroll.defer();

它们都检查窗口是否等于顶部,如果是,则 document.documentElement.doScroll('left'); 用于检查就绪状态。但是为什么在 window != top 时不使用它呢?

最佳答案

This bug report对于 YUI 库,框架文档中的 doScroll 与在顶层运行时的工作方式不同(当文档未准备好时不会抛出错误)。

关于javascript - IE DOMContentLoaded documentElement.doScroll,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10801625/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com