zoukankan      html  css  js  c++  java
  • 禁止复制文本的代码 HTML

    Html代码  收藏代码
    1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">  
    2. <HTML>  
    3. <HEAD>  
    4. <TITLE> javascript 双击取消html 页面 右键、选择文本 禁用 限制 </TITLE>  
    5.   
    6. </HEAD>  
    7.   
    8. <BODY  
    9. oncontextmenu="self.event.returnValue=false"  
    10. onselectstart="return false" ondblclick="func1()">  
    11. javascript 双击取消html 页面 右键、选择文本 禁用 限制  
    12. hyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy8888888888888888888888888  
    13.   
    14. <script>  
    15. function func1(){  
    16. //alert("x");  
    17. //window.document.oncontextmenu = function(){ };  
    18. //alert(window.document.oncontextmenu);  
    19. window.document.oncontextmenu = function(){ self.event.returnValue=true;}//默认为 null;  
    20. window.document.onselectstart = function(){ return true;}  
    21. }  
    22. </script>  
    23. </BODY>  
    24. </HTML>  
    Html代码  收藏代码
    1.   
    Html代码  收藏代码
    1. <pre class="html" name="code">function click(e) {   
    2. if (document.all) {   
    3.   if (event.button==1||event.button==2||event.button==3) {   
    4.    oncontextmenu='return false';   
    5.   }   
    6. }   
    7. if (document.layers) {   
    8.   if (e.which == 3) {   
    9.    oncontextmenu='return false';   
    10.   }   
    11. }   
    12. }   
    13. if (document.layers) {   
    14. document.captureEvents(Event.MOUSEDOWN);   
    15. }   
    16. document.onmousedown=click;   
    17. document.oncontextmenu = new Function("return false;")   
    18.   
    19. var travel=true   
    20. var hotkey=17   /* hotkey即为热键的键值,是ASII码,这里99代表c键 */   
    21. if (document.layers)   
    22. document.captureEvents(Event.KEYDOWN)   
    23. function gogo(e)   
    24. { if (document.layers) {   
    25. if (e.which==hotkey&&travel){   
    26. alert("操作错误.或许是您按错了按键!");  } }   
    27. else if (document.all){   
    28. if (event.keyCode==hotkey&&travel){ alert("操作错误.或许是您按错了按键!"); }}   
    29. }   
    30.   
    31. document.onkeydown=gogo   
    32. 把上面的代码另存为一个JS文件,然后在想实现此效果的页面调用即可!   
    33.   
    34. ===================================================   
    35.   
    36. 把下列代码放到<body></body>或者<head></head>之间   
    37. <script LANGUAGE="JavaScript">    
    38. function click() { if (event.button==2)    
    39. {alert('你好,右键已被禁止使用'); } } document.onmousedown=click   
    40. </script>   
    41.   
    42.   
    43. ===================================================   
    44.   
    45. 禁止点击鼠标右键1:   
    46.   
    47. <SCRIPT language=JavaScript>   
    48. <!--   
    49. file://锁鼠标右键和键盘CONTEXTMENU键   
    50. function click(e) {   
    51. if (document.all) {   
    52. if (event.button==2||event.button==3) { alert("欢迎光临寒舍,有什么需要帮忙的话,请与站长联系!谢谢您的合作!!!");   
    53. oncontextmenu='return false';   
    54. }   
    55. }   
    56. if (document.layers) {   
    57. if (e.which == 3) {   
    58. oncontextmenu='return false';   
    59. }   
    60. }   
    61. }   
    62. if (document.layers) {   
    63. document.captureEvents(Event.MOUSEDOWN);   
    64. }   
    65. document.onmousedown=click;   
    66. document.oncontextmenu = new Function("return false;")   
    67. // -->   
    68. </SCRIPT>   
    69.   
    70. 二、禁止点击鼠标右键2:   
    71.   
    72. <!--将以下代码加入HTML的<HEAD></HEAD>之间-->   
    73. <script language="javascript">   
    74. function click() {   
    75. if (event.button==2) {   
    76.   alert('欢迎光临寒舍,有什么需要帮忙的话,请与站长联系!谢谢您的合作!!!')   
    77.   }   
    78. }   
    79. document.onmousedown=click   
    80. </script>   
    81.   
    82. 三、禁止鼠标右键3(推荐):   
    83.   
    84. <script language="JavaScript" type="text/JavaScript">   
    85. <!--   
    86. function MM_reloadPage(init) {  //reloads the window if Nav4 resized   
    87.   if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {   
    88.     document.MM_pgW=innerWidthdocument.MM_pgH=innerHeightonresize=MM_reloadPage; }}   
    89.   else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();   
    90. }   
    91. MM_reloadPage(true);   
    92. //-->   
    93. </script>   
    94. </head>   
    95. <body leftmargin=0 topmargin=0 onmousemove='HideMenu()' oncontextmenu="return false" ondragstart="return false" onselectstart   
    96. ="return false" onselect="document.selection.empty()" oncopy="document.selection.empty()" onbeforecopy="return false"   
    97. onmouseup="document.selection.empty()">   
    98. <noscript><iframe src=*></iframe></noscript> </pre>  
    99.    
    100.    
     
  • 相关阅读:
    阿里云 redis 通过rinetd 进行端口透传
    Linux文件系统的实现
    门外汉的IT
    被解放的姜戈05 黑面管家
    被解放的姜戈04 各取所需
    被解放的姜戈03 所谓伊人
    统计Go, Go, Go
    被解放的姜戈02 庄园疑云
    被解放的姜戈01 初试天涯
    亚马逊云架设WordPress博客
  • 原文地址:https://www.cnblogs.com/mvc2014/p/3670842.html
Copyright © 2011-2022 走看看