English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Prevent Text Selection When Mouse Moves in JavaScript

This is to implement the function of prohibiting mouse selection through CSS styles:

unselectable is prepared for IE

onselectstart is prepared for Chrome and Safari

-moz-user-select is FF's

css style:html,body{-moz-user-select: none; -khtml-user-select: none; user-select: none;}

or

<div unselectable="on" onselectstart="return false;" style="-moz-user-select:none;">

Screening selected style definition:-moz-user-select attribute (only supported by ff).

The attribute has three attribute values:

1, none: Use none, all text of child elements cannot be selected, including the text in the input box also cannot be selected.

2, -moz-all: All text of child elements can be selected, but the text in the input box cannot be selected.

3, -moz-none: All text of child elements cannot be selected, but the text in the input box is an exception.

That's all for this article. I hope the content of this article can bring you some help in learning or work, and I also hope to get more support for the Yelling Tutorial!

Statement: The content of this article is from the Internet, and the copyright belongs to the original author. The content is contributed and uploaded by Internet users spontaneously. This website does not own the copyright, has not been manually edited, and does not assume relevant legal liability. If you find any content suspected of copyright infringement, please send an email to: notice#oldtoolbag.com (Please replace # with @ when sending an email for reporting, and provide relevant evidence. Once verified, this site will immediately delete the suspected infringing content.)

You May Also Like