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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With