Manu Viswam
Manu Viswam

Reputation: 1646

Bubble up mousemove event on iframe to the container div

I have the following code

<div onmousemove="myFunction()">
  <iframe src="www.someotherdomain.com"/>
</div>

I want myFunction to be executed when user moves his mouse over the iframe. Is it possible to bubble up the events on iframe to the parent element in cross domain scenario? How will I do this?

PS:- I can't use the solution provided in

Iframe obstructing the mousemove event from occuring

or

How do you send a mousemove event from an iframe back to the parent using jquery?

because I want the user to be able to interact with the content in the iframe.

Upvotes: 1

Views: 1510

Answers (1)

mplungjan
mplungjan

Reputation: 177950

I can see only one way.

Disable the session timer when mousing into the iframe and enable it when mousing out.

To do this, add a margin in the div and use mouseenter plus mouseleave from the outer div and vice versa on the way out.

If the window loses focus you may also want to enable the timer

Upvotes: 2

Related Questions