Reputation: 119
I use this code to prevent the visitors of my website to copy-paste its content.
<script>document.addEventListener('contextmenu', event => event.preventDefault());</script>
<script>element.on(?:copy|cut|paste)</script>
I was wondering if it were possible to exclude one URL from this script? It would help since it's for the tracking and customers would use copy-paste
Let me know, thanks you in advance :)
Upvotes: 1
Views: 566
Reputation: 162
Instead of
document.addEventListener('contextmenu', event => event.preventDefault());
you could do something like
document.addEventListener('contextmenu', event => {
if (window.location.href !== 'http://example.com/exclude/') {
event.preventDefault()
}
});
Upvotes: 1