I want to catch clicks that occur anywhere in an iframe. I can not directly access the iframe because it contains content from another domain. So how would I do that with jQuery? Somehow calculate if the click occurred in the area of the iframe? The iframe should stay totally accessible as it contains links etc.
+2
A:
This is impossible due to the Same origin policy. jQuery cannot magically circumvent the browser environment.
You may wish to implement a same-domain proxy (example in php) that passes the target site's html through to your iframe. You didn't mention what server-side technology you are using so I cannot be more specific.
Crescent Fresh
2009-09-30 17:58:07
But what about tracking mouse movement and telling whether it is over the iframe. You don't need to access the iframe for that, do you?
webjunkie
2009-10-01 17:30:40
Correct, you don't need the iframe's DOM to track mouse movements over it. However you specifically say in your question: "iframe should stay totally accessible". I take that to mean you cannot intercept events overtop of the iframe and need them to actually hit the iframe.
Crescent Fresh
2009-10-01 17:43:54