PDA

View Full Version : IFrame onclick question


thehog
05-03-2005, 05:35 PM
I know that the IFrame element does not have an onClick event handler. However, I need to execute a history.go(-1) when the user clicks somewhere in the iframe in the following example:


<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="style.css" type="text/css">

<script language="JavaScript">

function init() {
/* load content in the iframe */
document['frame'].location.href="<%= sFileName %>";

/* How do I set the onclick handler for the content in the iframe? */
...
}

</script>
</head>

<body onLoad="javascript:init()">
<iframe name="frame" width="100%" height="100%" scrolling="no" frameborder="no" marginwidth="0" marginheight="0">
</body>

</html>


Thanks,
-- theHog

SpirtOfGrandeur
05-03-2005, 09:03 PM
I believe that you need to capture the event on the IFRAME page. Then call its parents history to go back -1

;)

thehog
05-04-2005, 10:19 AM
Yes, but most of the time, the content in the ifame is ony a PNG file w/o HTML code (<iframe src="../image.png">).

I need to capture the mouse click one the object in the iframe.

glenngv
05-05-2005, 01:56 PM
Since the iframe src is a non-HTML file, you can't set any event handler in it.

Mr J
05-05-2005, 07:08 PM
Deleted my post