
5

利用js代码禁止鼠标选择和右键功能
source link: https://www.huhexian.com/25792.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

利用js代码禁止鼠标选择和右键功能
每个人创建一个网站只是为了向用户展示内容。默认情况下,用户可以复制和选择网站的内容。然而,有些朋友不希望他们网站的内容被别有用心的人复制走。他们可以通过js代码禁止鼠标相关的操作,比如禁止右键功能和选择功能。
将下方代码放进head或者foot中:
- <script language=JavaScript>
- document.oncontextmenu=new Function("event.returnValue=false;");
- document.onselectstart=new Function("event.returnValue=false;");
- </script>
虽然网页可以限制鼠标的功能,不过别人也会查找破解的方法。
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK