...
div>
Declared in global.css
#myArticle{
width:400px;
height:300px;
}
In this case, it is impossible to obtain the value of 400px through getElementById('myArticle').style.width directly through JS, because this value is defined in CSS, so other methods must be used. I wrote the following function:
/**
* function for get the style value in special css file
* @param int css_file_id
* @param String labname
* @param String param
*/
function getStyleValue(css_file_id,labname,param)
{
var tar;
var rss;
var style;
var value;
tar = document.styleSheets[css_file_id];
rss = tar.cssRules?tar.cssRules:tar.rules
for(i=0;i{
style = rss[i];
if(style.selectorText.toLowerCase() == labname.toLowerCase())
{
value = style.style[param]; }
}
return value;
}
Now just pass
getStyleValue(0,'#myArticle','width')
You can get it :)