I was using Firefox today and suddenly discovered a small problem. The former is used for IE and the latter is used for mozilla browser.
]
And the counts of rules and cssRules The methods are also different! rules is the selector number; cssRules is the rule number. You can see this by running the following code using IE and firefox respectively.
If you need to introduce external Js, you need to refresh to execute <script>
if(document.styleSheets[0].cssRules){
alert(document.styleSheets[0].cssRules[0].style.cssText)
}else{
alert(document.styleSheets[0].rules[0].style.cssText)
}
</script>]<script>
if(document.styleSheets[0].cssRules){
alert(document.styleSheets[0].cssRules[1].selectorText+":"+document.styleSheets[0].cssRules[1].style.cssText)
}else{
alert(document.styleSheets[0].rules[1].selectorText+":"+document.styleSheets[0].rules[1].style.cssText)
}
</script>
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