Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"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). The frame is opened using the jquery library thickbox (not maintained anymore...).

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:

$(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. In my case I can't remove one of the JS because the two pages are on different domains.

Thanks for your help.

like image 917
Maxime Rossini Avatar asked Feb 14 '26 21:02

Maxime Rossini


1 Answers

This is related to the following Firefox bug:

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

Possible solutions include setting the iframe's width and height to 0 or visibility to hidden, rather than using display: none.

like image 161
Andy E Avatar answered Feb 17 '26 10:02

Andy E



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!