I have tried the following code but it is not working in full screen.

  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);      
    });
 }-*/;
有帮助吗?

解决方案

  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);      
    });
  }-*/;
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top