我仅使用HTML + Javascript。
的HTML:
<input type="text" id="mobile" placeholder="Mobile Number" class="input-control">
<img src="pic/download.jpg" onclick="chat()">
Javascript:
function chat(){
var **mobile** = document.getElementById("mobile").value
location.href="https://api.whatsapp.com/send?phone=**"mobile"**&text=Hello%20World
}
您可以如下所示进行操作。但请注意,我注释掉了实际上将重定向浏览器远离StackOverflow的行。
function chat(){
let mobile = document.getElementById("mobile").value;
//assemble the new URL
let newUrl = `https://api.whatsapp.com/send?phone=${mobile}&text=Hello%20World`;
alert(newUrl);
/*** uncomment next line to redirect the browser ***/
//location.href=newUrl;
}
<input type="text" id="mobile" placeholder="Mobile Number" class="input-control">
<img src="pic/download.jpg" onclick="chat()">
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句