简体   繁体   中英

How can I move mouse in browser window?

I'd like to move mouse in my site browser window like here: www.lmsify.com. How can I do this? (javascript, flash, activex)

Regards, LisaM

They're not really moving the mouse cursor (you can't do that with browser-based JavaScript; I can't speak for Flash and I stay away from ActiveX), they're moving an image that looks like a mouse cursor (in their case, http://www.lmsify.com/cursor.png ).

You can move elements around the page using positioning (absolute, relative) and position properties ( left , top , right , bottom ). For instance, here's how to make an absolutely-positioned version of that cursor jump left and down each time it's clicked:

document.getElementById('theImage').onclick = function() {
  var left, top;

  left = parseInt(this.style.left, 10) + 10;
  top  = parseInt(this.style.top, 10) + 10;
  this.style.left = left + "px";
  this.style.top = top + "px";
};

Live copy

But obviously that's very crude. Various libraries like jQuery , Prototype + script.aculo.us , YUI , Closure , or any of several others can help you animate elements.

You can't move the mouse cursor in a browser. It can be simulated by moving an image with JavaScript or flash.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM