Electron:在Windows上禁用粘贴

3

我正在使用Electron,尝试禁用用户将内容粘贴到可编辑内容的能力。 我仍然保留了“粘贴并匹配样式”的功能。 在Mac上运作良好,但在Windows上,即使没有指向粘贴功能的键加速器,仍然可以进行普通的粘贴。 如何禁用此功能?

1个回答

2

将输入的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">


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接