Cross-browser method to prevent all methods of text copying from a textarea?

前端 未结 4 865
生来不讨喜
生来不讨喜 2021-01-18 08:46

I am working on an online typing software. In the typing software, all is going well but I have the problem of dishonest users who might possibly type the text into the text

4条回答
  •  渐次进展
    2021-01-18 09:35

    You maybe could do something like:

    var txtArea = document.getElementById("YourTextAreaId");
    txtArea.oncopy = function() { return false; } 
    txtArea.onpaste = function() { return false; } 
    txtArea.oncut = function() { return false; } 
    

    But even then, the user can copy the content by other means, as suggested in your question.

提交回复
热议问题