Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Set image showing blank 2

Status
Not open for further replies.

mattquantic

Programmer
Joined
Mar 28, 2004
Messages
196
Location
GB
Hi. When using:

document.getElementById('theimageid').src = "root to the image";

The image does seams to load, but not show. If I click properties the url is correct. If I select 'show image' from the right click menu - the image appears correctly.

Has anyone else had this issue when trying to load and control images using JS?

Has anyone found a working workaround?

M@)
 
Do you have a URL we could find this at? There are a number of causes of this kind of problem, but without something more specific, no one can offer you any real help.

Lee
 
When you click on the image, you have both a call to your function, as well as a javascript: void(0) call. The void(0) seems to be cancelling out the display of the image. Replace the javascript:void(0) with the function call to swap the image and delete it from the image onclick, or delete the javascript:void(0).

I'd guess that the onclick is being called immediately, then voided as the click bubbles up to the <a href>, with just enough time to blank the large photo out but not enough to load the next picture before void(0) is called.

Lee
 
You can also just add return false; to the end of your onclick (so that it never bothers to try the href once the onclick is done).

Code:
onclick="setMainImage('...');[!]return false;[/!]"

Cheers,
Jeff

[tt]Jeff's Page @ Code Couch
[/tt]

What is Javascript? FAQ216-6094
 
Hey matt, maybe you could think about sending out a few votes for tipmaster of the week when you get help on TT. Your TT profile ( shows that you have asked 52 questions on tek-tips and have never given out any stars. It takes little to no time to do and helps mark your post as informative in case anybody else stumbles across the same question later on down the road.

All you have to do is click "Thank **** for this valuable post", you can do it for more than one person in a thread, but only once for each person in a thread. Additionally, you don't have to be the one to start a thread to award a star.

-kaht

[small] <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <.</B>[/small]
[banghead] [small](He's back)[/small]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top