简体   繁体   English

Firefox中的“c.defaultView.getComputedStyle()为空”问题

[英]“c.defaultView.getComputedStyle() is null” issue in Firefox

I'm using jquery in a page on domain "abc.com", and this page opens an iframe on domain "def.com", which also uses jquery (same version, and I tried different ones from 1.5.2 to 1.6.4). 我在域“abc.com”上的页面中使用jquery,此页面在域“def.com”上打开一个iframe,它也使用jquery(相同版本,我尝试了从1.5.2到1.6的不同版本)。 4)。 The frame is opened using the jquery library thickbox (not maintained anymore...). 使用jquery库thickbox打开框架(不再维护...)。

My problem occurs in Firefox (any version from 3.X to 8.0), where I get the javascript error "c.defaultView.getComputedStyle(a, null) is null" the first time I load the iframe, and thus can't access any jquery initialization method: 我的问题发生在Firefox(从3.X到8.0的任何版本),我在第一次加载iframe时,我得到javascript错误“c.defaultView.getComputedStyle(a,null)为null”,因此无法访问任何jquery初始化方法:

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

On any other browser (chrome, ie, opera...) the code works, but in firefox I have to reload manually the iframe (right click -> this frame -> reload)... I have read some posts here on SO about similar issues, and each time the problem is a conflict between the two jquery libraries. 在任何其他浏览器(铬,即歌剧...)代码工作,但在Firefox中我必须手动重新加载iframe(右键单击 - >此框架 - >重新加载)...我在这里阅读了一些关于SO的帖子关于类似的问题,每次问题是两个jquery库之间的冲突。 In my case I can't remove one of the JS because the two pages are on different domains. 在我的情况下,我无法删除其中一个JS,因为这两个页面位于不同的域上。

Thanks for your help. 谢谢你的帮助。

This is related to the following Firefox bug: 这与以下Firefox错误有关:

Bug 548397 - window.getComputedStyle() returns null inside an iframe with display: none 错误548397 - window.getComputedStyle()在iframe中返回null,显示:none

Possible solutions include setting the iframe's width and height to 0 or visibility to hidden, rather than using display: none . 可能的解决方案包括将iframe的宽度和高度设置为0或将可见性设置为隐藏,而不是使用display: none

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Firefox的currentStyle与getComputedStyle问题 - Firefox issue with currentStyle vs getComputedStyle 如何修复TypeError:在firefox中,window.getComputedStyle(...)为null? - how to fix TypeError: window.getComputedStyle(…) is null in firefox? Firefox getComputedStyle返回“自动” - Firefox getComputedStyle returns “auto” IE和Firefox中的getComputedStyle()和cssText - getComputedStyle() and cssText in IE and Firefox 如何在DOMParser生成的文档中使用getComputedStyle(没有defaultView或window对象)? - How to use getComputedStyle with DOMParser produced document (no defaultView or window objects)? document.defaultView.getComputedStyle 和 window.getComputedStyle 有什么区别 - what's the difference bewteen document.defaultView.getComputedStyle and window.getComputedStyle getComputedstyle - IE8问题 - getComputedstyle - IE8 issue getcomputedstyle 对象 javascript 问题 - getcomputedstyle object javascript issue 尝试获取“背景”的值时,getComputedStyle在Firefox中返回NULL,但在Chrome中有效 - getComputedStyle returns NULL in Firefox when trying to get value for “background”, but works in Chrome Kenout React Grid在弹出窗口内:为什么getComputedStyle对于IE11和Edge返回null,但对于Chrome,Opera和Firefox不返回null? - Kendo React Grid inside Popout window: why getComputedStyle returns null for IE11 & Edge, but not for Chrome, Opera and Firefox?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM