<!DOCTYPE HTML> <html lang="en-US"> <head> <meta charset="UTF-8"> <title></title> </head> <body> 测试demo </body> <script type="text/javascript"> document.onselectstart=new Function("event.returnValue=false");//禁止选中(无法复制) //document.oncontextmenu=new Function("event.returnValue=false");//取消鼠标右键 function click(e){ if (document.all){ if (event.button==2||event.button==3) { alert("欢迎光临!"); 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;") document.onkeydown =document.onkeyup = document.onkeypress=function(){ if(window.event.keyCode == 123){ window.event.returnValue=false; return(false); } } </script> </html>