详解Html页面中内容禁止选择、复制、右键的实现方法

实现起来其实很简单,只需要在网页中加入以下标签(注意是紧随body后):

[hide] 

<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()">
​

[/hide]

版权说明:若无特殊注明,转载请保留文章出处
文章分类: 技术教程
字数统计:本文共有 744 个
本文链接:http://blog.442442.xyz/jishujiaocheng/234.html

标签:

精彩评论

发表评论: