/    Sign up×
Community /Pin to ProfileBookmark

images not loading

I have a function here to swap images back and forth through an onClick event that works fine in a standard flat html file. However when I plop it into my jsp page, sometimes the images show, and sometimes they come up broken. Is this a simple preload issue or maybe more extensive? Here is the function and the implementaion….

<script language=”javascript”>
function chng(c_img, swap1, swap2) {
if (c_img.src.indexOf(swap1)!= -1) c_img.src = swap2;
else c_img.src = swap1;
}
</script>

<a href=”javascript:displaySwitching(‘courseOverview’);”><img src=”/educator_root/images/btns/btn_show-crse-details.gif” width=”131″ height=”23″ alt=”” border=”0″ onclick=”chng(this,’/educator_root/images/btns/btn_show-crse-details.gif’,’/educator_root/images/btns/btn_hide-crse-details.gif’)” name=”courseDetail” /></a>

[the href value is controlling a show/hide div layer down lower on the page]

thanks

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@JonaJun 23.2003 — [font=arial][color=maroon]Well, is your DTD (DOCTYPE) the XHTML 1.1 or 1.0 one? If so, use ID instead of NAME, because NAME is not an XHTML attribute--and does not exist. That would be the basis of your problem. Of course, you may have to change your code alittle ([i]may[/i]) to suit the update.[/color][/font]

[b]Jona[/b]
Copy linkTweet thisAlerts:
@wynton_caauthorJun 23.2003 — Here is my doctype:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">

The images swap. However, in IE they always appear on load but sometimes do not 'load' when clicked. The majority of the time they click and load normally as I expect, however Id say maybe 1 in every 10 clicks results in a broken image. Interestingly, in Netscape, the page loads with the images correctly, and even swaps to the correct image on the first click, but consequently after that, no images load onclick. Outside of the .jsp the function works correctly, however inside the jsp the code seems to break in random ways. The images are also being assigned different names based on a java/jsp looping through an iteration of items that come directly out of a database.
Copy linkTweet thisAlerts:
@JonaJun 23.2003 — [font=arial][color=maroon]Then your problem is a database one. Ensure that all of the images exist and that your JSP functions are getting the correct results. Also, please provide a link to your page.[/color][/font]

[b][Jona][/b]
×

Success!

Help @wynton_ca spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...