开发者

images not appearing from javascript

开发者 https://www.devze.com 2023-01-12 11:04 出处:网络
On my home page, I have four boxes, and when you click on them, javascript expands them (gradually), and when you click again, it makes it smaller.

On my home page, I have four boxes, and when you click on them, javascript expands them (gradually), and when you click again, it makes it smaller.

The one thing I can't figure out is that in the top l开发者_如何学Pythoneft hand corner there should be a closebox icon. This isn't displaying for me. I'm not an expert in javascript but I think this is the line of code that calls the image

    inImage2.setAttribute('src',zoomImagesURI+'closebox.png');

The closebox.png is currently in the images folder, and the zoomImagesURL is currently set to:

var zoomImagesURI   = '/images/';

I don't even mind if the closebox image isn't there, but in Firefox when you view the page, the outline is there where the image should be, just the image is not displayed. In internet explorer no image, or outline appears.

Any help would be appreciated, thanks!


Just a random thought here... Your 'images' folder is in the web root? As this would set the image src to "/images/closebox.png", maybe this should be in "images/closebox.png").

If that is the question, then you should only change the zoomImagesURI to 'images/';


try using an absolute location for your folder:

var zoomImagesURI   = 'http://www.mywebsite.com/images/';

also make sure that inImage2 is an image object.

console.log(inImage2.nodeName);
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号