Alex wrote:
<html>
<body>
<form>
<input type="textbox" id="myTxt" value="what's my width?"
onClick="alert(this.width)">
</form>
</body>
</html>
how can I get a handle on the width of that textbox? Or can I at all?
<form action="">
<input type="textbox" id="myTxt" value="what's my width?"
onClick="
var msg;
var elem = this;
// IE method
if (elem.currentStyle) {
msg = elem.currentStyle['width'];
// W3C method
} else if (window.getComputedStyle) {
var compStyle = window.getComputedStyle(elem, '');
msg = compStyle.getPropertyValue('width');
} else {
msg = 'The methods I tried ain\'t '
+ 'supported by your browser.';
}
alert(msg)">
</form>
However, you will notice that IE very helpfully returns "auto" if
you haven't specified a width. Firefox gives a response in px.
Courtesty of:
<URL:http://www.oreillynet.com/pub/a/javascript/excerpt/JSDHTMLCkbk_chap5/index5.html>
--
Rob