Prevent user from copying text on mobile browsers

前端 未结 11 2114
陌清茗
陌清茗 2021-02-20 01:57

I\'m trying to develop a typing speed competition using JavaScript. People should write all the words they see from a div to a textarea.

To prevent cheating (like copyin

11条回答
  •  旧时难觅i
    2021-02-20 02:14

    A simpler solution than the accepted one would be to simply use a canvas element with filltext

    var canvas = document.getElementById("myCanvas");
    var ctx = canvas.getContext("2d");
    ctx.fillText("Can't copy this", 5, 30);

    JSFiddle example

提交回复
热议问题