禁止右键菜单代码、禁止复制粘贴代码

  • 禁止右键菜单代码、禁止复制粘贴代码已关闭评论
  • 62 views
  • A+
所属分类:SEO优化

代码如下:

  1. <script?type="text/javascript">
  2. //屏蔽右键菜单
  3. document.oncontextmenu?=?function?(event){
  4. if(window.event){
  5. event?=?window.event;
  6. }try{
  7. var?the?=?event.srcElement;
  8. if?(!((the.tagName?==?"INPUT"?&&?the.type.toLowerCase()?==?"text")?||?the.tagName?==?"TEXTAREA")){
  9. return?false;
  10. }
  11. return?true;
  12. }catch?(e){
  13. return?false;
  14. }
  15. }
  16. //屏蔽粘贴
  17. document.onpaste?=?function?(event){
  18. if(window.event){
  19. event?=?window.event;
  20. }try{
  21. var?the?=?event.srcElement;
  22. if?(!((the.tagName?==?"INPUT"?&&?the.type.toLowerCase()?==?"text")?||?the.tagName?==?"TEXTAREA")){
  23. return?false;
  24. }
  25. return?true;
  26. }catch?(e){
  27. return?false;
  28. }
  29. }
  30. //屏蔽复制
  31. document.oncopy?=?function?(event){
  32. if(window.event){
  33. event?=?window.event;
  34. }try{
  35. var?the?=?event.srcElement;
  36. if(!((the.tagName?==?"INPUT"?&&?the.type.toLowerCase()?==?"text")?||?the.tagName?==?"TEXTAREA")){
  37. return?false;
  38. }
  39. return?true;
  40. }catch?(e){
  41. return?false;
  42. }
  43. }
  44. //屏蔽剪切
  45. document.oncut?=?function?(event){
  46. if(window.event){
  47. event?=?window.event;
  48. }try{
  49. var?the?=?event.srcElement;
  50. if(!((the.tagName?==?"INPUT"?&&?the.type.toLowerCase()?==?"text")?||?the.tagName?==?"TEXTAREA")){
  51. return?false;
  52. }
  53. return?true;
  54. }catch?(e){
  55. return?false;
  56. }
  57. }
  58. //屏蔽选中
  59. document.onselectstart?=?function?(event){
  60. if(window.event){
  61. event?=?window.event;
  62. }try{
  63. var?the?=?event.srcElement;
  64. if?(!((the.tagName?==?"INPUT"?&&?the.type.toLowerCase()?==?"text")?||?the.tagName?==?"TEXTAREA")){
  65. return?false;
  66. }
  67. return?true;
  68. }?catch?(e)?{
  69. return?false;
  70. }
  71. }
  72. </script>
唯心寒辞