0

我已经尝试了以下代码,但它不能在全屏模式下工作。

  public static native void hello1()
/*-{
   var body=$doc.getElementsByTagName("body")[0];
 var posx=0;
  var posy=0;

     body.addEventListener("click",function (e)
      {
    if (e.clientX ||e.clientY)
        {
            posx = e.clientX;
            posy = e.clientY;
        }
alert('Mouse position is: X='+posx+' Y='+posy);      
    });
 }-*/;
4

1 回答 1

0
  public static native void hello1()
/*-{
 var body=$doc.getElementsByTagName("body")[0];
 var posx;
 var posy;

   $wnd.addEventListener("click",function (e)
    {
     if (!e) var e = $wnd.event;
if (e.pageX || e.pageY)
{
    posx = e.pageX;
    posy = e.pageY;
}
 else if (e.clientX ||e.clientY)
        {
            posx = e.clientX+$doc.body.scrolleft+$doc.scrollleft;
            posy = e.clientY+$doc.body.scrolltop+$doc.srolltop;
        }
alert('Mouse position is: X='+posx+' Y='+posy);      
    });
  }-*/;
于 2014-04-09T11:25:27.957 回答