문제

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