简体   繁体   English

禁用document.execCommand(“copy”)为false

[英]Disabling document.execCommand(“copy”) to false

How can I make my selected string to null. 如何将选定的字符串设为null。 So that I am not able to paste. 所以我无法粘贴。 I tried with document.execCommand('copy') = false; 我尝试使用document.execCommand('copy') = false; But it didn't work. 但它没有用。 Can I get any solution?. 我可以得到任何解决方案吗?

You can always rewrite execCommand to ignore copy 您始终可以重写exe​​cCommand以忽略副本

document._execCommand = document.execCommand;
document.execCommand = function () {  
  if (arguments[0] !== 'copy') return document._execCommand.apply(this, arguments);
  return false;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM