Вопрос

I would like to trigger a tel:12345 HREF using only Javascript, not with an anchor. I simply want to grab the value of an input field and use JS to prompt the user to call the number typed in. My trigger will be a button located next to the field.

Suggestions?

Это было полезно?

Решение

Use:

window.open('tel:12345');

Другие советы

<button onclick="myFunction()">
Call
</button>

function myFunction(){
var a = document.getElementById('input').value;
window.location.href = 'tel:' + a;
}
You can also view the live version on my website:
https://www.theharnishes.com/phone.html

Here we make a button and assign a function to it that bassically select the input, get the value, and the window.location.href will have the value of the input and it'll sent the url to call any number. 

Js call making is very simple. Using our : onclick function , Location , and tel We can do this in any tag, window . location ('tel:number')

Click me to call 199
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top