简体   繁体   English

如何在浏览器窗口中移动鼠标?

[英]How can I move mouse in browser window?

I'd like to move mouse in my site browser window like here: www.lmsify.com. 我想在我的站点浏览器窗口中移动鼠标,如下所示:www.lmsify.com。 How can I do this? 我怎样才能做到这一点? (javascript, flash, activex) (JavaScript,Flash,ActiveX)

Regards, LisaM 此致,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 ). 他们并没有真正移动鼠标光标(使用基于浏览器的JavaScript不能做到这一点;我不能说Flash,而我远离ActiveX),他们正在移动看起来像鼠标光标的图像(在这种情况下, 请访问http://www.lmsify.com/cursor.png )。

You can move elements around the page using positioning (absolute, relative) and position properties ( left , top , right , bottom ). 您可以使用定位(绝对,相对)和位置属性( lefttoprightbottom )在页面上移动元素。 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. 各种库,例如jQueryPrototype + script.aculo.usYUIClosure其他几种库都可以帮助您为元素设置动画。

You can't move the mouse cursor in a browser. 您无法在浏览器中移动鼠标光标。 It can be simulated by moving an image with JavaScript or flash. 可以通过使用JavaScript或Flash移动图像来模拟它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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