只能获取行间样式 : 标签.style.样式名
获取非行间样式
标准浏览器:getComputedStyle(标签).样式名
IE浏览器:标签.currentStyle.样式名
//2.标准浏览器:getComputedStyle(标签).样式名
var width = getComputedStyle(oDiv).width;
alert(width);
//3. IE浏览器:标签.currentStyle.样式名
var width = oDiv.currentStyle.width;
alert(width);
/*
4.兼容(方法[函数]的兼容)
方式:拿其中一个方法作为判断条件,如果有这个方法,就用,没有就用另外一个 xx.xx
如果方法是直接调用的[开头直接是xx()],前面加window
*/
/* if(oDiv.currentStyle){
var width = oDiv.currentStyle.width;
}else{
var width = getComputedStyle(oDiv).width;
}
*/
if(window.getComputedStyle){
var width = getComputedStyle(oDiv).width;
}else{
var width = oDiv.currentStyle.width;
-
this的概念