I have been successful at disabling the ability to highlight text in Safari on iOS using:

-webkit-user-select: none;

However, I do want to be able to highlight the text. I only don't want the copy box to show up.

Is there any way I can do this?

有帮助吗?

解决方案

You could try disabling right click along with ctrl+c. Here is a javascript method for disabling right mouse clicking:

<script type="text/javascript">
function catch_click(e)
{
    if (!e) var e = window.event;

    var right_click = (e.which ? (e.which == 3) : (e.button == 2));

    if (right_click)
    {
        alert('Right clicking on this page is not allowed.');
        return false;
    }
}

document.onmousedown = catch_click;
if (document.captureEvents) document.captureEvents(Event.MOUSEDOWN);
</script>

And here is one in jquery that disable copy/paste:

$(document).ready(function () {
    $('#Selector').bind('copy paste', function (e) {
       e.preventDefault();
    });
  });

So basically allow users to select the field but disable ways of copying it.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top