简体   繁体   English

mailto:和tel:在android webbrowser中

[英]mailto: and tel: in android webbrowser

I am developing a html webpage for show in an android/ios/windows phone app inside a webview. 我正在开发一个HTML网页,以便在webview内的android / ios / windows手机应用中显示。

I have this kind of links: and the same with mailto:"mail@mail.com" 我有这种链接:与mailto相同:“ mail@mail.com”

In ios works fine, also in chrome, firefox... But in webviews's webbrowser in android detects it as normal link and shows an inexistent webpage (This url cannot be found bla bla bla) 在ios中可以正常工作,在chrome,firefox中也可以。。。但是在android的webviews的webbrowser中,将其检测为正常链接并显示了不存在的网页(无法找到该网址bla bla bla)

Is there a way to avoid this in android? 有没有办法避免这种情况在Android? or should I detect browser in javascript and load the href or not? 还是应该在javascript中检测浏览器并加载href?

I found this for javascript: var browser = navigator.appName; 我为javascript找到了它:var browser = navigator.appName;

But I read this is not a good practice. 但是我看这不是一个好习惯。

Disable the automatic Linkify of Webview 禁用Webview的自动Linkify

There is a way to do that - rather ugly, two layered, but still a workaround. 有一种方法可以做到这一点-相当丑陋,分为两层,但是仍然可以解决。

You should 你应该

  1. modify how the webview will handle the auto-linkifiable items 修改网络视图如何处理可自动链接的项目
  2. explicitly tell the loaded page not to apply styles and haptic feedback 明确告诉加载的页面不要应用样式和触觉反馈

     mWebView.setWebViewClient( new WebViewClient() { @Override public boolean shouldOverrideUrlLoading(WebView view, final String url) { Uri uri = Uri.parse(url); if (url.startsWith("http:") || url.startsWith("https:")) { return false; } //TODO analyse the uri here //and exclude phone and email from triggering any action return false; } public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {} public void onPageFinished (WebView view, String url) {...} public void onPageStarted(WebView view, String url, Bitmap favicon) {...} public void onLoadResource(WebView view, String url) {...} }); 

In the html specify the following meta tags inside the tag: 在html中,在标记内指定以下meta标记:

<meta name="format-detection" content="telephone=no" />
<meta name="format-detection" content="email=no" />

Hope this helps. 希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM