Compatibility processing pageX 2

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Document</title>
  <style>
    body {
      height: 1000px;
    }
  </style>
</head>
<body>
  <script src="common.js"></script>
  <script> 
    // e.clientX / e.clientY mouse position in the visible region 
    //  
    // e.pageX / e.pageY mouse position on the page after IE9 compatibility problem is supported 
    
    // pageY + = clientY scrolling a page out from 

    the document.onclick =  function (E) { 
      E = E || the window.event; 
      the console.log (the getPage (E) .pageX); 
      the console.log (the getPage (E) .pageY); 

    } 

    // Get the mouse position on the page, the browser compatibility processing 
    function the getPage (E) {
       var the pageX = e.pageX || e.clientX + getScroll () the scrollLeft;.
       var pageY = e.pageY || e.clientY + getScroll().scrollTop;
      return {
        pageX: pageX,
        pageY: pageY
      }
    }



  </script>
</body>
</html>

 

Guess you like

Origin www.cnblogs.com/jiumen/p/11416485.html