我有一个页面 A.html 我嵌入了 B.html ,我想在A.html中获得鼠标位置,有一个问题,当我的鼠标在 iframe 元素上点击A.html时,它不会显示鼠标位置
A.html
<style>
.iframe_1{height:150px; width: 150px; top:360px; left:365px; overflow:hidden;
position:absolute;}
</style>
<iframe id="iframe" class="iframe_1" src="http://www.example.com/B.html">
</iframe>
my.js
document.onclick=getMouPo;
function getMouPo(ev){
if ( ev == null )
ev = window.event;
var point = {
x:0,y:0
};
if ( typeof window.pageYOffset != 'undefined'){
point.x = window.pageXOffset;
point.y = window.pageYOffset;
}
else if(typeof document.compatMode != 'undefined' && document.compatMode != 'BackCompat'){
point.x = document.documentElement.scrollLeft;
point.y = document.documentElement.scrollTop;
}
else if(typeof document.body != 'undefined'){
point.x = document.body.scrollLeft;
point.y = document.body.scrollTop;
}
point.x += ev.clientX;
point.y += ev.clientY;
alert (point.x +","+ point.y);
return point;
} // getMouPo(ev)