Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disabling the 'Copy' feature in iPad Safari browser

In Safari for iPad in iOS6, I would like to select text and then highlight it (changing the background color) using JavaScript. However, when I do text selection a "Copy" option automatically pops up. How would I go about disabling this "Copy" option? I'm able to get this working on every other browser, except on iPad Safari.

Is this possible? What should I do?

like image 648
RTores Avatar asked Feb 11 '13 16:02

RTores


1 Answers

If you want to disable the 'Cut / Copy / Paste' invoked by holding down on an element in Safari on the iPhone or iPad use the css:

-webkit-user-select: none;

Info from the Disabling ‘hold to copy’ on Mobile Safari, posted by Ben Collier


the -webkit-tap-highlight-color property accepts any standard CSS color value, but you’ll probably want to provide an rgba value in order to control the alpha transparency. Disabling the tap highlight is as simple as setting the alpha value to 0, like so:

container {
  -webkit-tap-highlight-color: rgba(0,0,0,0);
}

Info from Quick Tip: Customizing the Mobile Safari tap highlight color posted by Ryan Grove


So I would use css not javaScript.

like image 127
Comradsky Avatar answered Sep 28 '22 04:09

Comradsky