I have the following code with an invisible div that's over an iframe. I would like to get all the mouse events that are executed on the iframe (for now let's listen just to click
). But if I set the pointer-events
to none
, the click
listener is not called.
I tried to implement this as well, but without success: Add click event to iframe
My goal is to listen to any event that happens in the iframe and pop-up a message in the main window: "some event happend in the iframe". I don't care to know more info about the events in the iframe, just if they where triggered or not.
Note: The src
of the iframe is a different domain as the window.
Any ideas if this is possible?
jQuery(function($) { // DOM ready
$('#overlay').on('click', function(e) {
alert('test');
});
});
#frame {
z-index: 1;
width: 600px;
height: 400px;
position: absolute;
pointer-events: all;
}
#overlay {
width: 605px;
height: 405px;
opacity: 0;
background: red;
z-index: 9999;
position: absolute;
pointer-events: none;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<iframe id="frame" src="http://www.guguncube.com">
</iframe>
<div id="overlay">
</div>
here is http://jsfiddle.net/cxbmu/348/