1

I have a page A.html where I embed B.html, I want to get mouse position in A.html, there is a problem, when my mouse clicks on A.html when over the iframe element, it does not show me the mouse position

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)
4

0 回答 0