Click to See Complete Forum and Search --> : determine/change img width in nav


cul8er23
09-10-2003, 06:33 AM
Hi,
can anyone tell me how to determine image width and height in netscape and change it?

I am trying to postition one shaddow(pic) underneath every pic on my page to keep it small (I also need the pics w/out shadow).

--------------------------------------
<div style="position:absolute; z-index:2; top:100; left:100">
<img src="shaddow.png" name="cleaning_3_4_S">
</div>
<div style="position:absolute; z-index:3; top:101; left:101">
<img src="cleaning_3_4.jpg" name="cleaning_3_4">
</div>

<script type="text/javascript">
document.cleaning_3_4_S.width = document.cleaning_3_4.width/201 * document.cleaning_3_4_S.width;
document.imgName.width ;
</script>
--------------------------------------

Does anyone know how to do this in netscape?
Thanks in advance!!:)

Fang
09-10-2003, 01:10 PM
If your image has an id:
document.getElementById('img1').height
Or using the images array:
document.images[0].height

cul8er23
09-10-2003, 01:58 PM
Thanks for you reply,
but it doesn't work.
I added some comments...

<html>
<head>
<script language="JavaScript">

c_3_4 = new Image();
c_3_4.src = "cleaning_3_4.jpg";
c_3_4_Width = c_3_4.width;
c_3_4_Height = c_3_4.height;

c_3_4_S = new Image();
c_3_4_S.src = "shaddow2.png";
c_3_4_S_Width = c_3_4_S.width;
c_3_4_S_Height = c_3_4_S.height;

</script>
</head>
<body>

<div style="position:absolute; z-index:3; top:101; left:101">
<img src="cleaning_3_4.jpg" name="cleaning_3_4">
</div>
<div style="position:absolute; z-index:2; top:100; left:100">
<img src="shaddow2.png" name="cleaning_3_4_S">
</div>

<script language="javascript">
<!--
document.write(c_3_4_Width + " x " + c_3_4_Height + " Pixel <br>");
// '0 x 0 Pixel' in netscape6
document.write(document.cleaning_3_4.width + " x " + document.cleaning_3_4.height + " Pixel");
// '0 x 0 Pixel' in netscape6
// Therefore none of the below work
faktor = c_3_4_Width/201;
document.cleaning_3_4_S.width = faktor * document.cleaning_3_4_S.width;
c_3_4_S_Height = faktor * c_3_4_S_Height;
-->
</script>
</body>
</html>

I can't believe this is impossible ?!?

Fang
09-10-2003, 02:40 PM
I tried this with my own images, the results were correct for height and width.
The name or path for your images must be wrong.

cul8er23
09-10-2003, 03:14 PM
Does it really work in NETSCAPE???

Pathes are all ok. And it does work in IE properly.
Just Netscape6 is very incooperative :(
Maybe I didn't point that out ?!?

Thanks for your help!

Fang
09-11-2003, 03:55 AM
I did my check with Mozilla :rolleyes:
No, what you need is document.close(); after the last document.write(...);