ASM wrote:
> News a écrit :
>> I am trying to be able to manipulate the width and height of an
>> <img> but do not seem to be able.
>
>> <div class="ImgMnp" id="myImg" onmouseover="imgSize('myImg','fpImg)">
>> <img src="images/FirePlace.jpg" width="480" height="640" id="fpImg"
>> /> </div>
>>
>> Here is the JavaScript I tried to manipulate the <img>
>> function imgSize(myID,myImg)
>> {
>> var myDiv= document.getElementById(myID); //get correct <div>
>> var myImage=document.getElementById(myImg); //get correct <img>
>> var myWidth=myImage.style.width; //attempt to capture width of
>> <img> var myHeight=myHeight.style.height; //attempt to capture
>> height of <img> alert("myWidth+, +myHeight"); //show if I this
>> function works }
>>
>> Will someone please tell me what I am doing wrong
>
> simplest way :
>
> <img src="pict.jpg"
> onmousover="alert('width = '+this.width+' height = '+this.height)";>
>
> maybe your code would be better with :
>
> var myWidth= myImage.style&&myImage.style.width? myImage.style.width :
> myImage.width; //attempt to capture width of <img>
> var myWidth= myImage.style&&myImage.style.height?
> myImage.style.height : myImage.height; //attempt to capture height
> of <img>
> idea :
> If your image didn't get a width or height style, you can't catch it.
What does this mean??
> var myWidth= myImage.style&&myImage.style.width? myImage.style.width :
> myImage.width; //attempt to capture width of <img>
At first I thought it was a triune if true this else that type statement but
I don't have a clue what it is.
--
Totus possum, totum Deum.
Totus ero, totum meum.
WSW
Received on Mon May 1 05:14:15 2006