本文介绍了Firefox无法枚举document.styleSheets []。cssRules []的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是代码:




  • http://jsfiddle.net/salman/2hyYg/
  • http://jsfiddle.net/salman/2hyYg/show/

您会注意到警报(document.styleSheets [x] .cssRules.length)失败并显示安全异常。此解决方案的任何解决方法。我问,因为有几个CSS延迟加载类,使用此功能来检测是否加载CSS文档。

You'll notice the alert(document.styleSheets[x].cssRules.length) fails with a "security exception". Any workaround for this. I am asking because there are a couple of "CSS lazy loading" classes out there that use this feature to detect if the CSS document is loaded.

另外:安全异常是否是正确的行为/是否符合标准?

Also: is the security exception a correct behavior/does it conform to standards?

推荐答案

当尝试读取从其他域或服务器加载的样式表或尝试读取@import规则时,您可能会遇到此错误。

You can get that error when trying to read a stylesheet loaded from a different domain or server, or trying to read an @import rule.

你的目的,只需检查document.styleSheets.length。

For your purpose, just check the document.styleSheets.length .

这篇关于Firefox无法枚举document.styleSheets []。cssRules []的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 01:46
查看更多