在IE9中加载iFrame时,Jquery-ui会产生未指定的错误

时间:2011-10-26 14:47:01

标签: jquery iframe internet-explorer-9

我正在IE9中的iFrame中加载最新的jQuery和jQuery-ui。

我收到有关active = document.activeElement;的未指明错误。如果我深入研究jquery-ui代码并返回null:

active = null;

这解决了我的问题,因为从iFrame中启动时,IE9中未设置document.activeElement

我也在其他地方读过类似的问题:

https://github.com/jquery/jquery-mobile/issues/2064

我真的不想用try / catch编辑jquery-ui,但它是一个选项。

这个问题的最佳解决方案是什么?

2 个答案:

答案 0 :(得分:4)

阅读http://bugs.jquery.com/ticket/13378

最佳解决方案是在iFrame HTML

中添加以下脚本
/* Bug Fix: IE9 >>> http://bugs.jquery.com/ticket/13378 */
jQuery(function () { document.documentElement.focus(); });

答案 1 :(得分:1)

我认为问题是IE9在附加到DOM之前加载iframe的“src”,然后jQuery没有“文档”。