禁止网页复制-另存-右键等
2015-07-19 13:55
351 查看
如果你想你的网站内容不给人家复制,可以看看下面的实现方法:
//禁止鼠标右键
$(document).bind("contextmenu", function(e) {
return false;
});
//禁止键盘按键:
<script type="text/javascript">
function key() {
if (event.shiftKey) {
window.close();
}
//禁止Shift
if (event.altKey) {
window.close();
}
//禁止Alt
if (event.ctrlKey) {
window.close();
}
//禁止Ctrl
return false;
}
document.onkeydown = key;
</script>
<!-- 禁止选中内容 -->
<script type="text/javascript">
var omitformtags = ["input", "textarea", "select"]
omitformtags = omitformtags.join("|")
function disableselect(e) {
if (omitformtags.indexOf(e.target.tagName.toLowerCase()) == -1)
return false
}
function reEnable() {
return true
}
if (typeof document.onselectstart != "undefined")
document.onselectstart = new Function("return false")
else {
document.onmousedown = disableselect
document.onmouseup = reEnable
}
</script>
<!--禁止网页另存为: -->
<noscript>
<iframe src="/*"></iframe>
</noscript>
JS禁止网页复制和拷贝,只需要在body中加入部分代码即可
<body oncontextmenu="return false" onselectstart="return false" oncopy="return false">
还有另外一种方法,除了禁止另存外,其它功能基本上搞定:
<body oncontextmenu="return false" ondragstart="return false" onselectstart="return false"
onselect="document.selection.empty()" oncopy="document.selection.empty()" onbeforecopy="return false"
onmouseup="document.selection.empty()">直接加在body标签里即可
//禁止鼠标右键
$(document).bind("contextmenu", function(e) {
return false;
});
//禁止键盘按键:
<script type="text/javascript">
function key() {
if (event.shiftKey) {
window.close();
}
//禁止Shift
if (event.altKey) {
window.close();
}
//禁止Alt
if (event.ctrlKey) {
window.close();
}
//禁止Ctrl
return false;
}
document.onkeydown = key;
</script>
<!-- 禁止选中内容 -->
<script type="text/javascript">
var omitformtags = ["input", "textarea", "select"]
omitformtags = omitformtags.join("|")
function disableselect(e) {
if (omitformtags.indexOf(e.target.tagName.toLowerCase()) == -1)
return false
}
function reEnable() {
return true
}
if (typeof document.onselectstart != "undefined")
document.onselectstart = new Function("return false")
else {
document.onmousedown = disableselect
document.onmouseup = reEnable
}
</script>
<!--禁止网页另存为: -->
<noscript>
<iframe src="/*"></iframe>
</noscript>
JS禁止网页复制和拷贝,只需要在body中加入部分代码即可
<body oncontextmenu="return false" onselectstart="return false" oncopy="return false">
还有另外一种方法,除了禁止另存外,其它功能基本上搞定:
<body oncontextmenu="return false" ondragstart="return false" onselectstart="return false"
onselect="document.selection.empty()" oncopy="document.selection.empty()" onbeforecopy="return false"
onmouseup="document.selection.empty()">直接加在body标签里即可
相关文章推荐
- poj 3692Kindergarten(二分匹配模板)
- linux git
- C++笔记
- C#线程处理
- 输入框弹出键盘时自动上移
- python面试题目
- 小鹿课堂:5个迹象看透孩子隐藏的“心理疲劳”
- java的(PO,VO,TO,BO,DAO,POJO)类名包名解释
- 陈力:传智播客古代 珍宝币 泡泡龙游戏开发第三讲:html符号实体、超链接
- PHP关掉浏览器继续执行
- Tips on working with Theano
- NSString&NSMutableString常用操作梳理
- Making Sequences is Fun373B
- cell单元格高度自适应
- eclipse中创建tomcat服务器问题总结
- python的split用法
- CURD操作详解
- 用java 判断mysql中某个表是否存在
- 计算文字尺寸
- itoa()进制转换函数