Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

getElementById not working with Netscape Navigator, HELP!

Status
Not open for further replies.

gchen

Programmer
Nov 14, 2002
174
0
0
US
Hi,

I had a problem on below script which works perfect with MSIE but got error on NN saying -- document.getElementById is not a function.

Here is the script, TIA!

<html>
<head>
<title>Resizing</title>
<script language=javascript>

image_now = document.getElementById(&quot;image_now&quot;)

function Larger() {
if (document.getElementById(&quot;image_now&quot;).width <=300) {
document.getElementById(&quot;image_now&quot;).height *= 1.10;
document.getElementById(&quot;image_now&quot;).width *= 1.10;
}
}

function Smaller() {
if (document.getElementById(&quot;image_now&quot;).width >=100) {
document.getElementById(&quot;image_now&quot;).height *= 0.90;
document.getElementById(&quot;image_now&quot;).width *= 0.90;
}
}

</script>
</head>

<body bgcolor=&quot;ffffff&quot;>
<center>
<form method =&quot;post&quot;>
<input type=&quot;button&quot; value=&quot; Larger&quot; onclick=&quot;javascript:Larger();&quot;>
<input type=&quot;button&quot; value=&quot;Smaller&quot; onclick=&quot;javascript:Smaller();&quot;>
</form>
<!------------------------------------------>
<script language=javascript>
document.write(&quot;<img src= id=image_now width=160&quot;+&quot;>&quot;);
</script>
<!------------------------------------------>

</center>
</body>
</html>
 
gchen:

What version of NN are you using? This works fine on Netscape 6.1..


[yinyang]
Patrick
 
I guess, you mean Netscape 4.* (Netscape 6.* and 7.* should support it).
Netscape 4.* is too old to know about getElementById. To get a reference to image you do not need to use getElementById at all.
For example, you can use:
document[&quot;image_now&quot;].width
instead of:
document.getElementById(&quot;image_now&quot;).width

However, You will meet another problem. Netscape 4.* does not allow to resize already loaded image.

Regards,
Sergey Smirnov
Ask me directly at:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top