General discussion

Locked

Setting field size for certain browsers

By kirkk ·
Netscape Navigator displays textfields much longer than other browsers. So I need to determine which browser is being used, then set the size accordingly. I have the following javascript function:

function fieldLength()
{
if navigator.appName== "Netscape"
return 20;
else
return 40;
}

Now I need to plug the value into an input tag somehow:

<input name="textfield" size="
? fieldLength() ? ">

I've tried "javascript:fieldLength()" and document.write(fieldLength()) invarious syntaxes, but can't find the right solution. How can I make this work?

This conversation is currently closed to new comments.

2 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

Setting field size for certain browsers

by mightyduk In reply to Setting field size for ce ...

to the best of my knowledge, netscape will not let you resize the text box, however, IE does. So if you set the size initially to the size for netscape, and use this javascript it will check for non netscape browsers and set the appropriate size:
<script language="javascript">
function fieldLength(){
if (navigator.appName != "Netscape"){
document.frm.textfield.size=40;}
}
</script></head><body onload="fieldLength()">
....

Collapse -

Setting field size for certain browsers

by kirkk In reply to Setting field size for ce ...
Back to Web Development Forum
2 total posts (Page 1 of 1)  

Related Discussions

Related Forums