1. 程式人生 > >WEB頁面內容禁止選擇、複製、右鍵等實現

WEB頁面內容禁止選擇、複製、右鍵等實現

1.禁止右鍵:在<body>後面加入以下程式碼:

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

關鍵在於

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

2.禁止網頁另存為:在<body>後面加入以下程式碼:

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

3.禁止網頁內容複製.貼上:在<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()"