我有一个很奇怪的问题需要解决;该解决方案应该是纯JavaScript(不允许框架)。这里是:“显示在页面上启用的所有样式表”。document.styleSheets [i] .disabled在chrome中不起作用
因为在IE中有多个问题innerHtml
,所以我使用chrome,尽管它具有样式表的cssText
属性,它完全适合我的目的。
不管怎么说,这是我的榜样
<html>
<head>
<style MEDIA="screen">
h1 {color:blue; font-size:10pt; background-color:cyan}
</style>
<style MEDIA="screen" DISABLED="true">
h4 {color:blue; font-size:10pt; background-color:cyan}
</style>
<style MEDIA="print">
h1 {color:gray; font-size:12pt; font-weight: bold}
h2 {font-style:italic}
</style>
<style DISABLED="true">
h2 {color:green; font-size:12pt}
</style>
<style>
h3 {font-style:italic}
</style>
<script language="Javascript">
function displayActiveStyles() {
var container = document.getElementById('activeStyles');
var i;
for (i=0; i<document.styleSheets.length; i++) {
alert(document.styleSheets[i].disabled);
}
}
</script>
</head>
<body>
<h1>one</h1>
<h2>two</h2>
<h3>three</h3>
<input type="button" value="show" onclick="displayActiveStyles()" >
<hr />
<div id="activeStyles"></div>
</body>
</html>
的问题是,所有5种样式它提醒false
这是不正确的。如果任何人有任何想法我犯了一个错误,或者如果它可以在铬合金可行,请让我知道。
您的语言和用户名...有点冲突;) – Blender 2012-01-03 22:28:25
铬有报告的错误http://code.google.com/p/chromium/issues/detail?id=88310。谷歌正在使用铬源来构建他们的谷歌Chrome浏览器 – 2012-01-03 22:35:52
Blender,=)好点,会“废话”而不是胡说八道吗? – Clergyman 2012-01-04 18:39:00