Using JS to set image height in NS4.x

wxdqz

New Member
NETSCAPE 4.x

Hi, I am trying to set an image on my page to be the same as the height (not window.height) of the whole html page.

I can access the height of the page (not window) using:
document.height

Great! - or so I thought.



What I need to do now is set the height of an image to be equal to 'document.height'.

This can be done in a number of ways (I hope).

One method is putting the following code in the page:

<script language="JavaScript">
images = new Array
images[1] = "/images/tiny_invisible.gif";
var myimage = images[1]
document.write('<IMG src=http://www.webdeveloper.com/forum/archive/index.php/"' + myimage + '" width=1 height='+document.height+' border="1" alt="">')
</script>

The problem here is that it will only set its height to the height of the page above it, rather than the whole page. - this make sense as the rest of the page hasn't rendered yet, and therefore won't have a height.



What I need is something that is called one the page has initialised. So, as far as I see that leaves only <body onload="function();">

So, I used the function:

<SCRIPT LANGUAGE="JavaScript1.2">
<!--//
function gettheheight() { //v3.0
alert('document.height= '+document.height);
}//-->
</script>

Whoohay, now I have the total page height. All that remains is to set the height of an image on the page to be this height.

Easier said than done.

Initially, I tried the following:


Function:
<SCRIPT LANGUAGE="JavaScript1.2">
<!--//
function gettheheight() { //v3.0
document.myimage.height=document.height;
}//-->
</script>

And in the page:
<img src=http://www.webdeveloper.com/forum/archive/index.php/"image.gif" width="20" height="20" border="1" vspace="0" name="myimage">



Needless to say this didn't work. I have tried, I have read stuff. Now I'm going to the experts.

Is there anything that can be done to get this to work on netscape 4.x?

Any effort is hugely appreciated - been trying for a week.

M@
 
Back
Top