Is it possible to program a phone number in JS?

So, basically right now I can create a button with a tag A, where there is href = "tel: XXXXXXXXXXX", and if the user clicks / clicks on that he will bring them to his phone application. However, I'm trying to do this programmatically on gesture recognition (swipe the screen). The gesture works, I tried window.location = "tel:XXXXXXXXXX"; window.open('tel:XXXXXXXXXX', '_top'); window.location = "tel:XXXXXXXXXX"; window.open('tel:XXXXXXXXXX', '_top');

not one of them has yet worked. Any ideas? Ionic / Angular 1

Note ** This seems to only happen on iOS, Android seems to be working fine.

+5
source share
4 answers

If you want to do this via html, you just need to place the tag like this:

 <a href="tel:XXXXXXXXXX">Call me!</a> 

Similarly, if you want to do this through javascript, you can do:

 document.location.href = "tel:XXXXXXXXXX"; 
+8
source

To do this, you will need to add this first to the config.xml file

 <access origin="tel:*" launch-external="yes" /> 

then call it like this:

 document.location.href = "tel:XXXXXXXXXX"; 

White List Guide

+4
source

You probably just can't when your APP is launched from a mobile browser. You will need to wrap the application as a cordova application or similar. Then you can, for example, use PhoneGap-PhoneDialer

+2
source

You can try with one,

 window.location.href = "tel:+91123456789"; 

But for iOS, this may not work due to some resolution issues. In this case, you can try, as shown below,

 window.open('tel:+91123456789', '_system'); 
+1
source

Source: https://habr.com/ru/post/1259010/


All Articles