How can I access an iframes document event mouse position from the parent window using javascript and or jquery

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-06 09:59:18

This works, except for the permissions part.

JS:

$(document).bind("mousemove", function(e) {
    $("#result").html("x:" + e.pageX + ", y:" + e.pageY);
});

$($("#iframe1").contents()[0], window).bind("mousemove", function(e) {
    $("#result").html("x:" + (e.pageX) + ", y:" + e.pageY);
});

The problem was with .find(). I simply used the first index on the array returned by content, because an iframe is supposed to contain nothing but a document.

Updated with a better example.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!