il modo c'e',
ma quello che ti verra' restituito dipende molto dal browser e se la dimensione e' stata settata via css o meno;
sta a te interpretare il dato correttamente
Codice PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="it">
<head>
<title>font-size fisico in div</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<style type="text/css">
#id_div{
/* font-size:5em; */
}
</style>
<script type="text/javascript">
/*<![CDATA[*/
function getCssProperty(el,styleCss){
// se invece dell'oggetto fosse passato solo l'id, allora recupero l'oggetto
if(typeof(el)=='string') var el = document.getElementById(el);
// funzione per converite la sintassi Css in quella usata da Javascript
function toCamelCase(s) {
for(var exp = toCamelCase.exp;
exp.test(s); s = s.replace(exp, RegExp.$1.toUpperCase()) );
return s;
}
toCamelCase.exp = /-([a-z])/;
var styleJs=toCamelCase(styleCss);
// se l'elemento avesse già un valore inline (che predomina) restituisco quello
var value = el.style[styleCss];
if(!value)
// metodo x FF: vuole il nome della proprietà con la sintassi originale
if(document.defaultView) value = document.defaultView.getComputedStyle(el, null).getPropertyValue(styleCss);
// metodo x IE: vuole il nome della proprietà con la sintassi javascript
else if(el.currentStyle) value = el.currentStyle[styleJs];
return value;
}
window.onload=function(){
alert(getCssProperty('id_div','font-size'));
}
/*]]>*/
</script>
</head>
<body>
<div id="id_div">ciao mondo</div>
</body>
</html>
risultati (non specificando il font-size):
FF/Opera -> 16px
IE -> 12pt
(decommentando il font-size):
FF/Opera -> 80px
IE -> 5em
ciao