<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>javascript屏蔽浏览器右键功能按钮</title> <meta name="description" content="若是你不想别人扒掉你的模板,可以把这段js代码加到你网页上,即可屏蔽鼠标右键菜单、复制粘贴、选中等。" /> </head> <body> <script type="text/javascript"> //屏蔽右键菜单 document.oncontextmenu = 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.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> <div style="width:600px;margin:40px auto;text-align:center;border:solid 1px #FFCA52;background:#FFFDD2;height:28px;line-height:28px;font-size:14px;padding:5px 10px;color:#ff0000;font-weight:800;">
单页禁用右键菜单、粘贴、复制、剪切、选中操作</div> </body> </html> <!-- 以下是统计及其他信息,与演示无关,不必理会 --> <p class="vad"> <a href="http://www.sucaihuo.com/" target="_blank">sucaihuo.com</a> <a href="http://www.sucaihuo.com/js/824.html" target="_blank">说 明</a> <a href="http://www.sucaihuo.com/js/824.html" target="_blank">下 载</a> </p> <style type="text/css"> .vad { margin: 320px 0 5px; font-family: Consolas,arial,宋体,sans-serif; text-align:center;} .vad a { display: inline-block; height: 36px; line-height: 36px; margin: 0 5px; padding: 0 50px; font-size: 14px; text-align:center; color:#eee; text-decoration: none; background-color: #222;} .vad a:hover { color: #fff; background-color: #000;} .thead { width: 728px; height: 90px; margin: 0 auto; border-bottom: 40px solid #fff;} </style> <div style="width:728px;margin:0 auto"> <script type="text/javascript"> /*700*90 创建于 2015-06-27*/ var cpro_id = "u2176575"; </script> <script src="http://cpro.baidustatic.com/cpro/ui/c.js" type="text/javascript"></script> </div>