I'm trying to capture where the user clicks on the hole page but from an iframe inside an iframe.
so basically I can control where the user clicks on the 1st iframe from the 2nd iframe, but can't control where he clicks on the root document.
I've tried nearly everything and can't find an answer.
Here is my actuall javascript:
$(window, window.parent.document).document.click(function( event ) {
alert(event.target.nodeName );
});
for context, I'm using shadowbox as iframes and my objective is to control when a user clicks outside of the shadowboxes
$(window).documentin itself already returns undefined, you would need to de-reference the jQuery object first to get the "DOM version" of window,$(window)[0].documentBut turns out you can simply use
$(parent.document, parent.parent.document).click()That also kinda seems to be the most straight forward way to me.
(Don't know why
top.documentdid not work, because that is always the topmost window instance, so from within an iframe-inside-iframe that should be the same asparent.parent.document... or are there even more (i)frames involved, another level? Anyway, as long as you got something that works it doesn't really matter.)