我有一个带有iframe的网页呈现另一个页面(相同的域).我需要获取与父文档相关的鼠标位置.请注意,iframe可以双向滚动.我尝试过使用偏移而没有运气.
$('#iframe').contents().find('html').on('mousemove', function (e) {
//gives me location in terms of the iframe but not the entire page.
var y = e.pageY;
//gives me 0
var y = $(this).offset().top;
//more code here....
})
Run Code Online (Sandbox Code Playgroud)