Home  >  Article  >  Web Front-end  >  Firefox cannot obtain cssRules solution_javascript tips

Firefox cannot obtain cssRules solution_javascript tips

WBOY
WBOYOriginal
2016-05-16 19:25:261200browse

Firefox is too BT, and always adds some boring security permission settings to us. I have been discovering the FF compatibility of Qzone these days. After setting the domain, the cssRules of styleSheets cannot be obtained under FF.
Although the cssRules cannot be obtained, But I was surprised to find that I can actually insert and delete the styles in styleSheets. This is what kind of permissions, it’s boring.

It’s enough to give me insert and delete. Use these two methods You can also update the style. In order to make Firefox compatible with IE. I modified the prototype method of CSSStyleSheet

Copy the code The code is as follows:

CSSStyleSheet.prototype.addRule = function(selectorText,cssText,index){
return this.insertRule(selectorText cssText,index);
}
CSSStyleSheet.prototype.removeRule = CSSStyleSheet.prototype.deleteRule

In this way, firefox can also use IE’s addRule and removeRule.
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn