readium-shared-js
readium-shared-js copied to clipboard
Hightlighting when selection is disabled because of DRM restrictions
As stated in the title. This is for creating highlights when browser text selection is disabled to prevent copying & pasting.
(This was asked by someone else on today's call.)
You can give this a try:
ReadiumSDK.reader.on(ReadiumSDK.Events.CONTENT_DOCUMENT_LOADED, function($iframe, spineItem) {
var contentDoc = $iframe[0].contentDocument;
var contentWindow = $iframe[0].contentWindow;
contentDoc.body.oncopy = function() { return false; }
contentDoc.body.oncut = function() { return false; }
contentWindow.oncontextmenu = contentDoc.body.oncontextmenu = function(e) {
e.preventDefault();
return false;
}
});
It should work for all browsers. (IE8+ too)
What about CSS user-select: none, and also touch-callout: none?
`
To give my code snippet more context:
This is how you could prevent copy-pasting while keeping selection intact.
But you can still drag+drop, right? (just playing the devil's advocate, nit-picking :)