javascript: prevent page from blocking ctrl+c / ctrl+v
That depends on how it is done. Also, removing/disabling event listeners is always risky, you might harm the functionality of the site seriously - and you never know whether a handler does evil or good things, least you can know whether there is a handler at all.
So, I've skimmed the first few Google results for "javascript prevent copy paste" and found mostly foolish scripts: Disable pasting text into HTML form, Prevent Copy, Cut and Paste into HTML Input Text Fields, not working example. So what a script could do now:
- remove all on-copy, -paste, -input, -cut, -drag, etc properties of input elements
- capture these event types on the document and stop their propagation, so (bubble) handlers will never get called and can't prevent the default action
Yet, as already said, this can't hinder everything. The input
event, a very useful one, is cleverly used by this solution to prevent inserting more than one character at once. So you would need to decide whether you want to stop that event and possible break the application.
var evts = ["copy", "paste", "cut", "drag", "selectionstart?", "input?", …?];
var els = [document, document.body].concat(
[].slice.call(document.getElementsByTagName("input")),
[].slice.call(document.getElementsByTagName("textarea"))
);
function trap(e) { e.stopPropagation(); }
for (var i=0; i<evts.length; i++) {
var evt = "on"+evts[i].charAt(0).toUpperCase()+evts[i].substr(1);
for (var j=0; j<els.length; j++)
els[j][evt] = null; // remove handler
document.addEventListener(evts[i], trap, true); // capture phase
}