Make an iFrame trigger the body.onclick event?

Up vote 0 down vote favorite share g+ share fb share tw.

I have a script that attaches a function to be triggered by the the document. Onclick event. The problem is that the page has an iframe in it.

When the user clicks on the iframe, the document. Onclick event does not trigger the function attached to it. Is there any way to fix this?

In rare cases, the iframe may have another iframe inside of it as well that must also trigger the event. Note: I am not using jQuery. It's a great tool, but it is not the optimal solution this overall project.

Javascript events iframe javascript-events link|improve this question asked Feb 8 '11 at 20:16user396404341210 68% accept rate.

– cpara Feb 8 '11 at 20:19 I'm toying around with this idea and the one proposed by Daniel in his answer. Thank you. – user396404 Feb 8 '11 at 20:37.

Try ... console. Log(window.parent. Document); ... from within the iFrame.

If that works (you see it logged in the firebug console as an object) it's just a matter of finding the iframe element and attaching a click event to it. Var parent = $(window.parent. Document); // I'm using "iframe" but you'll need to find a more accurate selector.

$('iframe', parent). Click(function(){ alert('clicked'); }).

Thank you very much. – user396404 Feb 8 '11 at 20:36.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions