hi, i've got a one-line script that i'm using to change the 'src' of an image:
function enlargePhoto(the_photo) {
document.getElementById("large_photo").setAttribute("src","photos/" + the_photo + ".jpg");
}
i'm using the following bit of HTML to call the script:
<a href="javascript:;" onclick="enlargePhoto('DSC_0565');">load image</a>
first of all, it's an XHTML document, so the event handlers are all lowercase. it's not a capitalization problem.
the script works fine in Firefox and Safari, but in Internet Explorer the image doesn't show up. however, if i right-click where the image would be and use the "Show Image" context menu option, i can see that the 'src' of the image is getting replaced correctly.
what's totally weird about this is that when i change 'onclick' to 'onmouseover', the script works in Internet Explorer too. using 'onmouseup' (which is mechanically the same thing as 'onclick') does not work, while the handler 'onmousedown' does work.
so the problem seems to be that Internet Explorer isn't correctly interpreting the 'onclick' and 'onmouseup' handlers. i have tried it in IE6 and IE5, the result is the same.
so why doesn't 'onclick' work the same as any other event handler?
function enlargePhoto(the_photo) {
document.getElementById("large_photo").setAttribute("src","photos/" + the_photo + ".jpg");
}
i'm using the following bit of HTML to call the script:
<a href="javascript:;" onclick="enlargePhoto('DSC_0565');">load image</a>
first of all, it's an XHTML document, so the event handlers are all lowercase. it's not a capitalization problem.
the script works fine in Firefox and Safari, but in Internet Explorer the image doesn't show up. however, if i right-click where the image would be and use the "Show Image" context menu option, i can see that the 'src' of the image is getting replaced correctly.
what's totally weird about this is that when i change 'onclick' to 'onmouseover', the script works in Internet Explorer too. using 'onmouseup' (which is mechanically the same thing as 'onclick') does not work, while the handler 'onmousedown' does work.
so the problem seems to be that Internet Explorer isn't correctly interpreting the 'onclick' and 'onmouseup' handlers. i have tried it in IE6 and IE5, the result is the same.
so why doesn't 'onclick' work the same as any other event handler?