简体   繁体   中英

Page redirection for mailto and tel links on Android

I have a working Cordova iOS app. Now I am working on an Android app. I have a "contact us" page where I have a link:

 <a id="lnkEmail" style="border: none;box-shadow: none;text-align: left;" data-role="button"  href="#">  support@website.com          </a>

 $('#lnkEmail').on('click',function(){
         document.location.href = "mailto:support@site.com";
    });

The page is redirected to a "webpage not available" error page while the link opens in an email client. How do I stop page redirection? I have tried:

 <a style="border: none;box-shadow: none;text-align: left;" data-role="button"  **href="mailto:support@site.com"** target="_top">support@site.com </a>

As well as:

 <a id="lnkEmail" style="border: none;box-shadow: none;text-align: left;" data-role="button"  **href="javascript: void(0);"**>support@site.com</a>  support@site.com         </a>

How can I fix this ?

There is a bug on how the mailto is handled and it try to navigate to the page before loading the email client.

You can try using inAppBrowser plugin

window.open('mailto:support@site.com', '_system');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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