js代碼製做屏蔽瀏覽器右鍵菜單,屏蔽瀏覽器粘貼,屏蔽瀏覽器複製,屏蔽瀏覽器剪切,屏蔽瀏覽器選中,不會屏蔽搜索引擎蜘蛛抓取頁面,不影響seo優化。能夠設置網頁內容代碼不被用戶隨意下載等。javascript
方法一:示例代碼:java
<SCRIPT type="text/javascript">瀏覽器 //屏蔽右鍵菜單優化 document.oncontextmenu = function (event){搜索引擎 if(window.event){spa event = window.event;.net }try{htm var the = event.srcElement;索引 if (!((the.tagName == "INPUT" && the.type.toLowerCase() == "text") || the.tagName == "TEXTAREA")){seo return false; } return true; }catch (e){ return false; } }
//屏蔽粘貼 document.onpaste = function (event){ if(window.event){ event = window.event; }try{ var the = event.srcElement; if (!((the.tagName == "INPUT" && the.type.toLowerCase() == "text") || the.tagName == "TEXTAREA")){ return false; } return true; }catch (e){ return false; } }
//屏蔽複製 document.oncopy = function (event){ if(window.event){ event = window.event; }try{ var the = event.srcElement; if(!((the.tagName == "INPUT" && the.type.toLowerCase() == "text") || the.tagName == "TEXTAREA")){ return false; } return true; }catch (e){ return false; } }
//屏蔽剪切 document.oncut = function (event){ if(window.event){ event = window.event; }try{ var the = event.srcElement; if(!((the.tagName == "INPUT" && the.type.toLowerCase() == "text") || the.tagName == "TEXTAREA")){ return false; } return true; }catch (e){ return false; } }
//屏蔽選中 document.onselectstart = function (event){ if(window.event){ event = window.event; }try{ var the = event.srcElement; if (!((the.tagName == "INPUT" && the.type.toLowerCase() == "text") || the.tagName == "TEXTAREA")){ return false; } return true; } catch (e) { return false; } } </SCRIPT> |
方法二:示例代碼
在頁面的body內或者HEAD內增長如下代碼來屏蔽JS錯誤。 在頁面的body內或者HEAD內增長如下代碼來屏蔽右鍵部分功能。 |
方法三:
看代碼吧!在body標籤中添加以下代碼,就能禁止想要的功能。
禁止鼠標右鍵:oncontextmenu="return false";
禁止選擇:onselectstart="return false";
禁止拖放:ondragstart="return false";
禁止拷貝:oncopy=document.selection.empty() 。
禁止保存:<noscript><iframe src="*.htm"></iframe></noscript>,放在head裏面。
禁止粘貼:<input type=text onpaste="return false">
關閉輸入法:<input style="ime-mode:disabled">
屏蔽打印: <style>@media print{* {display:none}} </style>