有的时候,我们不希望自己网页中所呈现的内容不被别有用心盗取,就需要在网页中加上一个禁止复制的功能,而一般的浏览器在禁止复制后还可以用复制为纯文本,并不能完全杜绝此问题,此时就需要我们在页面中完全禁止右键和复制。
实现起来其实很简单,只需要在网页中加入以下标签(注意是紧随body后):
<body topmargin="0" oncontextmenu="return false" ondragstart="return false" onselectstart ="return false" onselect="document.selection.empty()" oncopy="document.selection.empty()" onbeforecopy="return false" onmouseup="document.selection.empty()">
这只是一个最初步的方法,也很容易被人破解,怕网页被别人另存为本地文件,可以再加上以下代码防止别人保存:
<noscript> <iframe src="*.htm"></iframe> </noscript>
最后,有的站长可能只需要一个禁止复制的功能,并不需要禁止右键,则在<body>中加入以下代码即可:
<body onmousemove=/HideMenu()/ oncontextmenu="return false" ondragstart="return false" onselectstart ="return false" onselect="document.selection.empty()" oncopy="document.selection.empty()" onbeforecopy="return false" onmouseup="document.selection.empty()">
Copyright © 2019- obuygou.com 版权所有 赣ICP备2024042798号-5
违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com
本站由北京市万商天勤律师事务所王兴未律师提供法律服务