html网页表单中禁用复制、右键、粘贴、剪切等方法
2015-01-17 14:40
621 查看
在网页开发中,有些时候我们不想让用户去复制或者粘贴该网页的东西,那么下面的几个方法就非常有用了,贡献给大家!
网页退出提示的方法:
移动端中,屏蔽类似iphone的默认滑动事件用一下方法:
//屏蔽右键菜单 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; } }
网页退出提示的方法:
window.onbeforeunload = function(event){ event = event || window.event; event.returnValue = ' '; }
移动端中,屏蔽类似iphone的默认滑动事件用一下方法:
//禁用浏览器的默认滑动事件 var preventBehavior = function(e) { e.preventDefault(); }; // Enable fixed positioning document.addEventListener("touchmove", preventBehavior, false);
相关文章推荐
- C#禁止textbox复制、粘贴、剪切及鼠标右键的方法
- Asp.net网页中禁止使用剪切、复制、粘贴的方法
- 禁止另存网页、屏蔽选中、粘贴、复制、剪切、右键菜单程序代码
- HTML,JS禁止鼠标右键、禁止全选、复制、粘贴的方法
- HTML,JS禁止鼠标右键、禁止全选、复制、粘贴的方法;
- 【转】禁止另存网页、屏蔽选中、粘贴、复制、剪切、右键菜单(精)自己
- 网页禁用右键、防拷贝及"另存为"失效方法
- wpf 复制/剪切到本地系统剪切板中以供右键粘贴用
- 常用的JS屏蔽功能(右键、查看源文件、复制、剪切、粘贴、后退、F1、F5、Ctrl+N、Shift+F10、Alt+F4)
- 实现JTextfield 的右键 复制、剪切、粘贴功能。
- 解决浏览网页禁用鼠标右键的方法
- silverlight:向TextBox添加右键菜单,菜单包括复制、粘贴、剪切、选择全部等四项功能!
- 网页禁用复制、禁用右键
- 网页中禁用右键菜单、选择、复制、拖拽、
- 终极屏蔽右键 / 禁止复制 / 禁止另存 / 禁止选取 / 禁止粘贴的方法
- 破解网页禁用鼠标右键方法
- 禁用IE的后退按钮|显示网页已过期|几种语言的实现方法|c#|javascript|html
- C# 打开文本文件,剪切文本,复制文本,粘贴文本方法
- 禁用IE的后退按钮|显示网页已过期|几种语言的实现方法|c#|javascript|html
- 反复制粘贴破解网页不能右键不能复制粘贴办法集锦