gpt4 book ai didi

javascript - ie9 标准模式、iframe 和 dom manip

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:06:49 27 4
gpt4 key购买 nike

IE9(标准模式)根本不允许您在 DOM 中操作 iframe。如果您使用 jQueryUI 对话框或 jQuery 的 .wrap() 函数来包装恰好包含 iframe 的内容,IE9 将会崩溃。事实上,您甚至不需要 jQuery,普通的旧 JS 就可以正常工作(见下文)。

我想知道自从 Microsoft says they do this on purpose to address a memory leak 以来人们对此有何看法.

我们不确定该怎么做。将我们所有使用 iframe 的文档置于 Quirks 模式似乎是错误的。但我们不确定替代方案是什么。有任何想法吗? TIA。

Javascript 示例代码:

       <p id="after"></p>

..将 iframe 放在这里...

        <script type="text/javascript">
//uncomment code below in IE9 standards mode to see error
//document.getElementById("after").appendChild(document.getElementById("iframe"));
</script>

最佳答案

遇到这个问题后,我屈服于将浏览器置于怪癖模式:

        Response.AddHeader("X-UA-Compatible", "IE=8");

绝对欢迎任何其他解决方案,因为像 tengoal 我怀疑这不是最佳选择,即使它有效

关于javascript - ie9 标准模式、iframe 和 dom manip,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5559221/

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