I'm having problems finding the width and height of an image. I'm trying to pass it to the URL so I can set it as a PHP session variable.
location.href="homeview.php?x=" + dd.elements.image1.x 开发者_StackOverflow+ "&y=" + dd.elements.image1.y + "&h=" + document.getElementById('image1').height;
the URL reads as such with an example image:
homeview.php?x=8&y=8&h=undefined
so I've tried
location.href="homeview.php?x=" + dd.elements.image1.x + "&y=" + dd.elements.image1.y + "&h=" + dd.elements.image1.height;
and its still undefined, my img tags are like this
<img id="image1" src="newimages/image1.png" width="45" height="45">
If it helps, the Javascript is run in a function at the bottom of the page. Any advice would help.
Thank you guys!!
try
document.getElementById('image1').offsetHeight;
https://developer.mozilla.org/en/DOM/element.offsetHeight
精彩评论