Style : Gets the inline style;
currentstyle: Gets the calculated style, also called the current style, the final style.
Pros: You can get the final style of an element, including the default value of the browser, rather than just the inline style, as a style, so it's more common.
Note: You cannot get composite styles such as background property values, only a single style such as Background-color, and so on.
alert (Oabc.currentstyle);
IE8 and Opera 11 pop Up "Object Cssstyledeclaration"; FF 12, Chrome 14, Safari 5 pops up "undefined".
var oabc = document.getElementById ("abc");
if (Oabc.currentstyle) {
IE, Opera
Alert ("I support Currentstyle");
} else {
FF, Chrome, Safari
Alert ("I do not support Currentstyle");
}
In fact, in the FF browser we can use getComputedStyle (obj,false) to achieve the same effect as currentstyle under IE.
getComputedStyle (Obj,false): In the new version of FF only the first parameter, that is, the Operation object, the second parameter write "False" is also common use, the purpose is to be compatible with the old version of the Firefox browser.
Compatible wording:
var oabc = document.getElementById ("abc");
if (Oabc.currentstyle) {
IE, Opera
Alert ("I support Currentstyle");
alert (oAbc.currentStyle.width);
} else {
FF, Chrome, Safari
Alert ("I do not support Currentstyle");
Alert (getComputedStyle (oabc,false). width);
}
JavaScript gets inline and non-inline styles--compatible notation