From: http://hi.baidu.com/lepharye/blog/item/53e622cfad5bd731f9dc61e0.html
Style sheets can be created in three ways:
Inline style: it is written in the tag. The embedded style is only valid for all tags.
Internal style sheet: it is written in the HTML
External style sheet: if many web pages are used in the same style (styles), write the style (styles(in a CSS file suffixed with .css, and then reference the CSS file on each page that requires these styles.
The following is a javascript code that reads styles other than embedded styles. It can only be read and cannot be written.
VaR Mydiv = Document. getelementbyid ( ' Mydiv ' );
If (Mydiv. currentstyle ){
VaR Width = Mydiv. currentstyle [ ' Width ' ];
Alert ( ' IE: ' + Width );
} Else If (Window. getcomputedstyle ){
VaR Width = Window. getcomputedstyle (mydiv, Null )[ ' Width ' ]
Alert ( ' Firefox: ' + width );
}< P>
In addition, you can obtain the document in the following way under FF
. defaultview. getcomputedstyle (mydiv, null ). width
window. getcomputedstyle (mydiv, null ). width
<meta http-equiv =" Content-Type "content =" text/html; charset = UTF-8 "> <br/> <style> # test {width: 200px ;} </style> <p> This is test content <p>
RUN Code