简体   繁体   中英

js: stop mouse movement

it's possible to stop mouse movement in window and allow only in certain box ?

for example, i have a div with width: 200px and height: 200px , to allow only in this div to move mouse.

Thank you.

Javascript can read mouse position but not set it. What I would do for that kind of things is place an element under the mouse and prevent the page element from moving outside of the bounds even.

Also I have seen this link in stackoverflow, maybe it can help you

https://developer.mozilla.org/en-US/docs/Web/API/Pointer_Lock_API

您能告诉我您实际要做什么吗,如果您想将鼠标指针隐藏在某个div中而不是可以使用css

.hidecousor { cursor:none; }

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