【问题标题】:"c.defaultView.getComputedStyle() is null" issue in FirefoxFirefox 中的“c.defaultView.getComputedStyle() 为空”问题
【发布时间】:2011-12-30 15:07:11
【问题描述】:

我在域“abc.com”的页面中使用 jquery,并且此页面在域“def.com”上打开一个 iframe,该 iframe 也使用 jquery(相同版本,我尝试了与 1.5.2 不同的至 1.6.4)。使用 jquery 库 thickbox 打开框架(不再维护...)。

我的问题出现在 Firefox(从 3.X 到 8.0 的任何版本)中,我在第一次加载 iframe 时收到 javascript 错误“c.defaultView.getComputedStyle(a, null) is null”,因此可以'不访问任何 jquery 初始化方法:

$(function() {
  /* Does not pass here in firefox */
});

在任何其他浏览器(chrome,即opera ...)上,代码都可以工作,但是在Firefox中我必须手动重新加载iframe(右键单击->此框架->重新加载)...我已经阅读了一些帖子这里关于类似问题的SO,每次问题都是两个jquery库之间的冲突。就我而言,我无法删除其中一个 JS,因为这两个页面位于不同的域中。

感谢您的帮助。

【问题讨论】:

    标签: javascript jquery firefox iframe cross-domain


    【解决方案1】:

    这与以下 Firefox 错误有关:

    Bug 548397 - window.getComputedStyle() returns null inside an iframe with display: none

    可能的解决方案包括将 iframe 的宽度和高度设置为 0 或将可见性设置为隐藏,而不是使用 display: none

    【讨论】:

      猜你喜欢
      • 2014-05-29
      • 2013-08-21
      • 1970-01-01
      • 2013-04-02
      • 2011-02-26
      • 2011-11-12
      • 2011-12-05
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多