javascript禁止复制网页内容可以通过以下方式实现:禁止鼠标右键+禁止选中文本。 代码很简单,只需要在head标签的javascript内加入以下两行代码即可。

document.oncontextmenu=function(e){return false;}
document.onselectstart=function(e){return false;} 

使用了jQuery的页面中可以这么写:

document.oncontextmenu=function(e){return false;}
$('body').bind("selectstart",function(){return false;});

注意:上面的代码在IE和Chrome下测试通过,但是在Firefox下鼠标右键不能用但依然可以选中文本,所以出于兼容性考虑, 需要在body的style中加入这么一个属性:

-moz-user-select:none; 

相关文章:

  • 2022-12-23
  • 2021-12-22
  • 2021-12-20
  • 2021-06-29
  • 2022-02-18
  • 2021-12-19
  • 2022-12-23
  • 2021-12-15
猜你喜欢
  • 2022-03-08
  • 2022-01-27
  • 2022-12-23
  • 2021-07-25
  • 2022-02-02
  • 2022-12-23
相关资源
相似解决方案