kalyson
06-15-2007, 04:34 AM
Hello,
I'm trying to add an event handler to various elements in an IFRAME. I've adding it to images, the body of the document, etc., and none of them work.
This code would be in the top frame's <SCRIPT> tags in the <HEAD> part of the document:
window.frames["map_target"].document.getElementById("map_image").onclick="myfunc('inside')";
In the IFRAME source document, I have this in the <HEAD> of that document:
<SCRIPT LANGUAGE="JavaScript">
function myfunc(s) {
alert(s);
return false;
}
</SCRIPT>
If I do this:
<IMG NAME="map_image" ID="map_image" SRC="http://newlightsoftware.com/map_ca.gif" BORDER="0" onclick="return myfunc('inside');">
and click on the image, it works. If I try to add the onclick event dynamically in the parent document, it does nothing. No errors or anything...
Does anyone see what I'm doing wrong? I looked for other examples like this but did not find any.
Thanks,
Kris
I'm trying to add an event handler to various elements in an IFRAME. I've adding it to images, the body of the document, etc., and none of them work.
This code would be in the top frame's <SCRIPT> tags in the <HEAD> part of the document:
window.frames["map_target"].document.getElementById("map_image").onclick="myfunc('inside')";
In the IFRAME source document, I have this in the <HEAD> of that document:
<SCRIPT LANGUAGE="JavaScript">
function myfunc(s) {
alert(s);
return false;
}
</SCRIPT>
If I do this:
<IMG NAME="map_image" ID="map_image" SRC="http://newlightsoftware.com/map_ca.gif" BORDER="0" onclick="return myfunc('inside');">
and click on the image, it works. If I try to add the onclick event dynamically in the parent document, it does nothing. No errors or anything...
Does anyone see what I'm doing wrong? I looked for other examples like this but did not find any.
Thanks,
Kris