小编mar*_*452的帖子

从iframe内部获取绝对鼠标位置

我有一个带有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)

javascript iframe jquery mouseover

5
推荐指数
1
解决办法
6184
查看次数

标签 统计

iframe ×1

javascript ×1

jquery ×1

mouseover ×1