ie与其他浏览器在通过js操作样式方面的异同
一、关于float
ie:div.styleFloat
others:div.cssFloat
二、关于动态计算样式
ie:div.currentstyle
others:document.defaultView.getComputedStyle(div,null) //不需要伪元素信息时,第二个参数为null,第二个参数伪元素字符串如,‘after:’
三、关于样式表
1、获取样式表styleSheet对象
ie:
var link=document.getelementbyTagName('link')[0];
var sheet=link.styleSheet;
others:
var link=document.getelementbyTagName('link')[0];
var sheet=link.styleSheet;
注:或者document.styleSheets[index]获取,通用
2、通过styleSheet对象获取样式规则
ie:sheet.rules
others:sheet.cssRules
3.操作规则
ie:
sheet.addRule(selector,cssText,index),例:sheet.addRule('div.color','red',5);//第三个参数是插入规则的索引
sheet.deteteRule(index),例:sheet.deteteRule(0);
others:
sheet.addRule(selector+cssText),例:sheet.addRule('div.color','red');
sheet.deteteRule(index),例:sheet.deteteRule(0);

浙公网安备 33010602011771号