How to call click-to-call using javascript (iphone)

I have a link on a mobile web page that should track the clickTag advertiser and then activate the click call.

Tracking works for me, but I don't know how to call tel:1800123456; using javascript. Any ideas? This is not a web application; this is a standard html page. I can use jQuery.

Update

Just calling window.open("tel:num"); after adding iframe tracking on click, it’s not reliable enough, because sometimes the call dialog opens until the iframe loads.

window.open("tel:num"); also opens a new window, after which the call dialog opens, which is not a great user interface on the iphone 3gs / 4.

+4
source share
2 answers

Do you have control over iframe tracking? If so, you can call a function that calls window.location after loading it. Sort of

 $(document).ready(function() { window.iframe_loaded(); }); 

in iframe code (if it has jQuery) and a function in your main script called iframe_loaded that calls window.location.

If you cannot install the code inside the iframe, but you can edit the code of the iframe container, you can do this ...

 <iframe id="whatever" onload="iframe_loaded();" width="400" height="200"></iframe> 

... therefore onload calls iframe_loaded (), which does window.location ...

If you don't have control over the iframe or its contents, then a simple kludge will just wrap the call to window.location in a timeout, i.e.

 setTimeout('window.location="tel:18001234567";', 500); 

500 at the end will delay him for half a second. (Enlarge it if your iframe is loading slowly.) It's not that elegant, but it might work fine, and users probably won't notice a slight delay!

+4
source

Have you tried window.open (url); where is the url "tel: 18001234567"?
Sounds like this should work, right?

+1
source

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


All Articles