Clear clipboard to prohibit unauthorised copying, insert message?

醉酒当歌 提交于 2019-11-28 14:18:16
Justin

You can't do it purely through JavaScript.

JavaScript editing of the clipboard is considered a security vulnerability (and there is much more discussion on this).

You could do it through hacks that uses Flash for clipboard access interacting with JavaScript.

You could place the following:

$( document ).ready(function() {
    if (event.ctrlKey && event.keyCode == 67) {
        var inputFieldClear = document.createElement("input");
        inputFieldClear.setAttribute("value", "Insert Default Value Here");
        document.body.appendChild(inputFieldClear);
        inputFieldClear.select();
        document.execCommand('copy');
        inputFieldClear.remove();
        console.log("Attempting to Alter Clipboard")
}});

That would work in something like TamperMonkey - not sure if it could be incorporated into the sites source or not.

Hope it helps! :)

James_pic

Yes, you can. The basic trick is that you detect when a user holds down Control, and select a different piece of text on the page.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!