View Full Version : NS not reading width property of image object
Hello All:
I have this:
var imgObj = new Image();
imgObj.src = currImage;
alert(imgObj.width);
currImage represents an image in the directory, not an image referenced from an IMG tag. In IE the alert will return 350, the width of the image. In NS it returns 0. Is there any reason why the difference in values between the two browsers?
Thanks in advance, Mike
Jon Hanlon
02-09-2003, 05:16 PM
What's currImage? Where does it get set? Please post more code.
One example, currImage equals '/images/nv_deserts/large/white_mtns_large.jpg', currImage is a global variable that gets set through a function that is called from the onClick event of a thumbnail on the page. A user clicks the thumbnail, the thumbnail calls a function to generate the large image using the value of currImage. (generateTag('/images/nv_deserts/white_mtns.jpg', 250, 167)) This file sits on the server under the specified directory. So I then make an image object:
var imgObj = new Image();
set the src property:
imgObj.src = currImage;
then I use this info in generating a query string to send to another page for generating a larger, zoomed in image. As I said before, IE shows me the correct width, 350, NS shows me the value, 0.
Hey Guys,
try this as a test:
function testPic() {
var obj = new Image();
obj.src = '/images/test.gif';
alert(obj.width);
}
-make an actual image called test.gif or point the src value to an image already existing. Call this function from an onClick or onMouseOver off anything in a page. Test the page in IE, do you get the width of your image returned? Try it in NS6, do you get a zero?
vBulletin® v3.6.7, Copyright ©2000-2009, Jelsoft Enterprises Ltd.