Hello, I don't understand why this function is not defined: function swapimg(in) { alert(in); var imgname; imgname = in; window.parent.document.getElementById('ifrmtarget').src="images/" + in + ".jpg"; } Code (markup): I'm calling it like this: <a href="#" onclick="swapimg(00)" > If you see the problem, would you please let me know. Thanks, Jason
Is this in a <script type="text/javascript"></script> tag in the <head></head> ? Also, try calling with: <a href="#" onclick="javascript:swapimg(00)" >
Try loading your page in Firefox and viewing the contents of the JavaScript console window (type javascript: into the location bar). It may tell you the error that's making the function undefined.
Please change like bellow: 1. Put the swapimg() in the parent page which has "ifrmtarget" and use document.getElementById('ifrmtarget').src =".." in swapimg() 2. In main page, set window.swapimg = swapimg; right after the your function definition 2. In the sub page loaded in main page, you can refer to swapimg() function by calling window.parent.swapimg("..");