在 iOS6
的 iPad
Safari 中,我想选择文本,然后使用 JavaScript 突出显示它(更改背景颜色)。但是,当我进行文本选择时,会自动弹出“复制”选项。我将如何禁用此“复制”选项?除了 iPad
Safari 之外,我可以在所有其他浏览器上使用它。
这可能吗?我该怎么办?
最佳答案
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;
来自 Disabling ‘hold to copy’ on Mobile Safari 的信息, 由本·科利尔 (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);
}
信息来自 Quick Tip: Customizing the Mobile Safari tap highlight color瑞安·格罗夫 (Ryan Grove) 发表
所以我会使用 css 而不是 javaScript。
关于javascript - 禁用 iPad Safari 浏览器中的 'Copy' 功能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14816031/