wynton_ca
06-25-2003, 11:23 AM
I know that Ive posted this before, but I couldnt find the posting. IN any case....I am running this script on a JSP page. For some reason, the script works fine in a flat HTML file, IE and netscape. In netscape it doesnt work at all and IE 90% of the time, in the jsp file. However, when I append an alert() in the script between the if/else statements, it works fine. What would be the cause of this, and why does an alert() statement force it to function? Is there anything else I could put in there, other than an alert() statement to make this function carry out and live a long happy life confined to it's web application?
<script language="javascript">
function chng(c_img, swap1, swap2) {
if (c_img.src.indexOf(swap1)!= -1) {
c_img.src = swap2;
alert("");
}
else {
c_img.src = swap1;
alert("");
}
}
</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')" id="courseOverviewImage" /></a>
thanks a million
<script language="javascript">
function chng(c_img, swap1, swap2) {
if (c_img.src.indexOf(swap1)!= -1) {
c_img.src = swap2;
alert("");
}
else {
c_img.src = swap1;
alert("");
}
}
</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')" id="courseOverviewImage" /></a>
thanks a million