在网页代码中禁止右键、禁止选择以及禁止下载网页的代码
- 在网页代码中禁止右键、禁止选择以及禁止下载网页的代码
发布时间:2010-02-05 类别:javascript技术 来源:侠客工作室 -
- 1
- 2
- 3
- 4
- 5
在网页代码中屏蔽右键、屏蔽选择以及禁止下载网页的代码
在网页代码中屏蔽右键、屏蔽选择的代码<body bgcolor="#ffffff" leftmargin="0" topmargin="0" marginwidth="0" marginheight="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()‘></body><noscript>
<iframe src="*"></iframe></IFRAME>
</noscript>另一种方法:在网页中调用以下js文件:<!--#include file="mouse.js" --><script language="javascript">
function click(e) {
if (document.all) {
if (event.button==1||event.button==2||event.button==3) {
oncontextmenu=‘return false‘;
}
}
if (document.layers) {
if (e.which == 3) {
oncontextmenu=‘return false‘;
}
}
}
if (document.layers) {
document.captureEvents(Event.MOUSEDOWN);
}
document.onmousedown=click;
document.oncontextmenu = new Function("return false;")var travel=true
var hotkey=17 /* hotkey即为热键的键值,是ASII码,这里99代表c键 */
if (document.layers)
document.captureEvents(Event.KEYDOWN)
function gogo(e)
{
if (document.layers)
{
if (e.which==hotkey&&travel)
{ alert("操作错误.或许是您按错了按键!"); } }
else if (document.all){
if (event.keyCode==hotkey&&travel){ alert("操作错误.或许是您按错了按键!"); }}
}document.onkeydown=gogo
</script>- ☆☆☆技术交流群:5684178☆☆☆
- 上一篇:网页禁止选择内容代码
- 下一篇:用js实现禁止复制 禁止右键