Prevent user from copying text on mobile browsers

前端 未结 11 2099
陌清茗
陌清茗 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条回答
  •  甜味超标
    2021-02-20 02:12

    Try putting a transparent div over the text. I have used jQuery here. That should work.

    var position = $('#textInHere').position();
    $('#noClickThroughThis').css({
        height: ($('#textInHere').height()),
        width:  ($('#textInHere').width()),
        position: 'absolute',
        top: position.top,
        left: position.left,
        'z-index': 100
    });
    

    Here is a fiddle http://jsfiddle.net/lacrioque/tc4bwejn/

提交回复
热议问题