最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Disable mobile Chrome 43's "Touch to Search" feature programmatically - Stack Overflow

programmeradmin3浏览0评论

When I select text in Chrome 43 on my Android device I get the "Touch to Search" popup. We're currently using text selection for a feature on our site and this new Chrome feature interferes with some of our UI.

In the long run, we'll be working out new UI/UX to work side-by-side with this feature, but in the interim, we want to disable it on our web app.

Is there some sort of meta tag or JavaScript we can add to turn this off? Does anyone know if this is currently possible?

When I select text in Chrome 43 on my Android device I get the "Touch to Search" popup. We're currently using text selection for a feature on our site and this new Chrome feature interferes with some of our UI.

In the long run, we'll be working out new UI/UX to work side-by-side with this feature, but in the interim, we want to disable it on our web app.

Is there some sort of meta tag or JavaScript we can add to turn this off? Does anyone know if this is currently possible?

Share Improve this question asked Jun 4, 2015 at 15:45 Benjamin SolumBenjamin Solum 2,32119 silver badges31 bronze badges
Add a comment  | 

5 Answers 5

Reset to default 17

This can be manipulated in a number of ways. The user can turn it off in flags as PaulI suggested, and you can control it.

Developer control, right now there are a couple of options but the basic summary is if we think it is an user interactable element then it won't be enabled:

  • CSS: -webkit-user-select: none;
  • HTML:
    • Anything with an aria-role will not have the touch to search enbabled
    • Anything with a tabindex of -1 or > 0

Possible workaround could be to wrap text in <button> tag. This obviously wouldn't work if talking about big blocks of text, but for other elements like titles, icons and other small stuff this works fine.

As of 2021, it isn't possible to disable touch-to-search (when this is triggered by a long-press for text selection) in chrome mobile. The article that Kinlan is referencing is apparently concerned only with touch-to-search triggered through a tap gesture.

Quoting donnd, from bugs.chromium.org:

Regarding #2 -- developer control: The 2015 article that you mentioned (https://developers.google.com/web/updates/2015/10/tap-to-search) focuses on triggering through the tap gesture. As you correctly point out, it does not address the long-press gesture triggering. Touch to Search responds to both tap and long-press but treats them differently. As I'm sure you know, the long-press gesture activates a whole set of features which can include copy, translation, smart text selection, and Web Search. A site developer can markup their page text as non-selectable in order to disable the long-press gesture entirely, but currently there's no way to disable only the Touch to Search response to long pressing. If you'd like to work with us to add such a feature, let us know and we'll file a separate feature request.

If you want disabled "touch to search" in a menu that has an action open / close (toggle), it is necessary to javascript :

event.preventDefault();

Navigate to about:flags or chrome:flags and look for Enable Contextual Search

Then toggle to Disabled and hit restart at the bottom.

发布评论

评论列表(0)

  1. 暂无评论