Forum Moderators: open

Message Too Old, No Replies

table width set in percent, how to get it in pixels?

document.<table_id>.width returns as percents, how to get the width in px?

         

Vano

4:09 am on Sep 19, 2004 (gmt 0)

10+ Year Member



Hello!
Does anyone know how to get "real" width of the table in pixels, when it set in percents?
currently if I use:
document.<table_id>.width
it returns value as 100% same as it set in HTML
but I'm wondering if there is a way get it in pixels?

Thank you

Rambo Tribble

4:39 am on Sep 19, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Try this, for example:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Untitled</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<style type="text/css">
html,body{height:100%;width:100%;margin:0;padding:0;}
#target{width:100%;height:100%;border:10px solid #e88;}
</style>
</head>
<body>
<table id="target">
<tr>
<td>
<a href="#"
onclick="alert(document.getElementById('target').offsetWidth+' & '+document.getElementById('target').offsetHeight);">
click here
</a>
</td>
</tr>
</table>
</body>
</html>

Vano

4:54 am on Sep 19, 2004 (gmt 0)

10+ Year Member



Thank you very much!
offsetWidth is what I was looking for.