简体   繁体   中英

How to call a parsed number in Phone gap?

Here is HTML file

 <div class="email">
<p style ="top:0;"><b id="email"></b</p>
<a href="https://accounts.google.com" style="top:10px;">
<img class="imgleft" src="css/gmail.png" style="height:30px;"/></a>

<p style ="top:30px; color:#45b3e0;"><b id="phone"></b></p>
<a href="#" onclick ='return phoneNumber()'style="top:45px;">
<img class="imgleft" src="css/phone.png" style="height:20px;"/></a>
</div> 

Here is JS file

function getInformation(){

var address,companyEmail,companyName,companyPhone,followupDate,leadDate,leadDetails,leadValue,contactPerson,followupAction,status;

address=localStorage.getItem("Address");
companyEmail=localStorage.getItem("companyemail");
companyName=localStorage.getItem("companyname");
companyPhone=localStorage.getItem("companyphone");
followupDate=localStorage.getItem("followupdate");
leadDate=localStorage.getItem("leaddate");
leadDetails=localStorage.getItem("leaddetails");
leadValue=localStorage.getItem("leadvalue");
contactPerson=localStorage.getItem("contactperson");
followupAction=localStorage.getItem("followupaction");
status=localStorage.getItem("Status");

//document.getElementById("description").innerHTML=Address;
document.getElementById("email").innerHTML=companyEmail;
document.getElementById("cname").innerHTML=companyName;
document.getElementById("phone").innerHTML=companyPhone;
document.getElementById("fdate").innerHTML=followupDate;
document.getElementById("Address").innerHTML=address;
document.getElementById("ldetail").innerHTML=leadDetails;
document.getElementById("lvalue").innerHTML=leadValue;
document.getElementById("name").innerHTML=contactPerson;
document.getElementById("faction").innerHTML=followupAction;
document.getElementById("status").innerHTML=status;   }
function phoneNumber(phone)
 {

    phone = Phone.replace(/[^0-9]/g, "");
    window.location = "tel:" + phone;
  }

I am working on Phone Gap application for android and IOS, Here I'm getting able to Parse Phone Number and Mail ID from the server but my question 1. when user click on call image that parsed number should get dial and same thing for Mailing?

Change html code as following

<div class="email">
    <p style ="top:0;"><b id="email"></b</p>
    <a href="mailto:test@gmail.com" style="top:10px;">
    <img class="imgleft" src="css/gmail.png" style="height:30px;"/></a>

    <p style ="top:30px; color:#45b3e0;"><b id="phone"></b></p>
    <a href="tel:+910000000000"> +91 00000 00000 style="top:45px;">
    <img class="imgleft" src="css/phone.png" style="height:20px;"/></a>
    </div> 

And add following in your config.xml file

<access launch-external="yes" origin="mailto:*" />
    <access launch-external="yes" origin="tel:*" />

it will open native mail system and native dialer to make phone calls.

add in config.xml

<allow-intent href="tel:*" />
<allow-intent href="mailto:*" />

check this link

and in html

<a href="mailto:test@email.com">text</a>
<a href="tel:1234">text</a>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM