有的時候,咱們不但願本身網頁中所呈現的內容不被別有用心盜取,就須要在網頁中加上一個禁止複製的功能,而通常的瀏覽器在禁止複製後還能夠用複製爲純文本,並不能徹底杜絕此問題,此時就須要咱們在頁面中徹底禁止右鍵和複製。
實現起來其實很簡單,只須要在網頁中加入如下標籤(注意是緊隨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()">