我有一個很奇怪的問題需要解決;該解決方案應該是純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