现在的位置: 首页 > 综合 > 正文

【javascript】FF和IE的区别一

2012年09月06日 ⁄ 综合 ⁄ 共 638字 ⁄ 字号 评论关闭
  <select id="w1" class="test1"></select>
  <label for="test2" id="w2"></label>
  <div class="test3" id="w3"></div>
<script type="text/javascript">
var foo=document.getElementById('w1');
var foo2=document.getElementById('w2');
var foo3=document.getElementById('w3');

alert(foo.getAttribute('class')) //w3c 
alert(foo.getAttribute('className')) //IE6 7

alert(foo2.getAttribute('for')) //w3c
alert(foo2.getAttribute('htmlFor')) //IE6 7

foo3.style.cssFloat='right' //w3c
foo3.style.styleFloat='right' //IE

foo3.style.opacity='0.5'; //w3c
foo3.style.filter='alpha(opacity=50)' //IE

IE8+ 和其他标准浏览器显示效果相同;值得注意的是label标签,在js中取属性for值的时候,IE6 7 是getAttribute('htmlFor');其他浏览器是getAttribute('for')

抱歉!评论已关闭.