我正在使用 Electron,我试图禁用用户粘贴到可编辑内容的功能。我还保持启用粘贴和匹配样式。这在 Mac 上效果很好,但由于某些原因在 Windows 上,即使没有指向粘贴功能的快捷键,正常粘贴仍然是可能的。我怎样才能禁用它?
最佳答案
为输入的 onpaste 函数返回 false。
例如:
document.querySelector('.noPaste').onpaste = () => false;
You can paste into this one:
<input>
<br/>
You can't paste into this one:
<input class="noPaste">
关于javascript - Electron:在 Windows 上禁用粘贴,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52769187/