JavaScript怪癖和秘密之FireFox浏览器下的RGB颜色实例页面
代码:
HTML代码:
<p id="somePara">Hello, world!</p> <button id="button">点击弹出结果</button>
JS代码:
document.getElementById("button").onclick = function() { var ie = navigator.appVersion.indexOf('MSIE') != -1; var p = document.getElementById('somePara'); alert(ie ? p.currentStyle.color : getComputedStyle(p, null).color); };
效果:
Hello, world!