开发者

Share Cursor Position on an element using jquery & php

Is it possible to share across the cursor position in an element say with the class="board" so that others can see it as a translucent circle or something?

  1. Is it possible to get the cursor position with jquery?
  2. Is it possible to pass them over to another use开发者_运维百科r and replicate it there with an image?
  3. If its possible, what will be the best method to do so?


You can get the mouse position using mousemove events:

$(document).mousemove(function(e){
    console.log(e.pageX +', '+ e.pageY);
}); 

If you want to transfer the information to another user, just send the coordinates via an XMLHttpRequest to your server and then bounce that data back to that user. This will give you a bit of lag, but that's to be expected.

If I correctly understand what you mean by "replicate it there with an image", just used a fixed-positioned cursor image (set with Javascript using the coordinates you receive) to simulate both cursors being there at once.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜