0

I used this code to prevent copy/paste function on my site, but in firefox it has disabled the search field too. :(

Is there any way to do this that excludes the input field in this code?

<script type="text/JavaScript">
    function killCopy(e) {
        return false;
    }
    function reEnable(){
        return true;
    }

    document.onselectstart = new Function("return false");
    if (window.sidebar) {
        document.onmousedown = killCopy;
        document.onclick = reEnable;
    }
</script>
yummypasta
  • 1,398
  • 2
  • 17
  • 36
Newsboy
  • 41
  • 1
  • 4
  • 5
    I honestly suggest you do NOT do that. It only hurts the user experience and doesn't protect from anything you think it protects. The "protection" can be trivially bypassed in addition to proving non-trivial to implement. Overall, you are literally wasting effort on this feature. If people _want_ to copy something they'll do it. At most they might go "oh, can't copy - I'll just use a different website", so it'll work, but not in the way you wanted. If they want to paste and you stop them...there is absolutely no good reason to do that, so people will also be directed away. – VLAZ Nov 04 '16 at 08:17
  • FWIW, when you're focused on helping users navigate an unfamiliar UI and you care about their experience and satisfaction, I think that limiting all possible interactions in not necessarily a bad thing. <2 cents/> – danwoods Nov 18 '16 at 16:41

0 Answers0