如何优雅的禁止页面复制,选中!

HTML页面内容禁止选择、复制、右键

刚在一个看一个站点的源代码的的时候发现的,其实原来真的很简单
<body leftmargin=0 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()'></body>
关键就在
oncontextmenu='return false'
ondragstart='return false' 
onselectstart ='return false' 
onselect='document.selection.empty()' 
oncopy='document.selection.empty()' 
onbeforecopy='return false' 
onmouseup='document.selection.empty()'
一个更简单的方法就是在中加入如下的代码,这样鼠标的左右键都失效了.
<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()" ></body>

1.禁止网页另存为:在后面加入以下代码:

<iframe src="*.htm"></iframe> 
</noscript>  

2.禁止网页内容复制.粘贴:在中加入以下代码:

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

转载自 HTML页面禁止选择、页面禁止复制、页面禁止右键 - WebEnh - 博客园

1 个赞