Principle: Use a tag to jump to the specified URL:
sms://[number]?body=[content]//Android
sms://[number]&body=[content]//ios
First of all, make two inputs, one for the input, and one for the sending number. Add another a tag.
The code is as follows
<! DOCTYPE html><Htmllang="ZH-CN" ><Head><Metacharset="UTF-8" ><title> Send SMS</Title></Head><Body><Formaction= "#" > < input id= "name" type= "text" > < input id= "tel" type= "text" > < a href= "#" > Send SMS </a></ Form></body></ HTML>
At this point, we want to get the value of two input and assign the HREF attribute to the a tag.
JS code is as follows
<Script>functionDoAction (){var u = navigator.useragent;var isandroid = U.indexof (' Android ') >-1 | | U.indexof (' Adr ') >-1;Android Terminalvar Isios =!! U.match (/\ (i[^;] +;( U;)? Cpu.+mac OS x/);//ios terminal var name = document.getElementById ( "name"). Value; var tel= document.getelementbyid ( "tel"). Value; if (isios) {document.getelementsbytagname ( ' a ') [0].href=" sms://"+tel+ else{document.getelementsbytagname ( ' a ') [0].href= "sms://" +tel+ "&body = "+name;} }</SCRIPT>
Then add a oninput time to the input tag to trigger doaction ().
Gracefully dust
Links: Https://www.jianshu.com/p/3d3224b85ee6
Source: Pinterest
Copyright belongs to the author. Commercial reprint please contact the author for authorization, non-commercial reprint please specify the source.
Preliminary discussion on JS-HTML5 Mobile send specified content SMS to specified number