实例如下:
<!doctype html> <html> <head> <meta charset="utf-8"> <title>database example</title> <script type="text/javascript" charset="utf-8" src="cordova.js"></script> <script type="text/javascript" charset="utf-8"> document.addeventlistener("deviceready", ondeviceready, false); function ondeviceready() { } function onsuccess(contact){ alert("save success"); } function onerror(error){ alert("error= "+error.code); } function createcontact(){ var contact =navigator.contacts.create(); contact.displayname="张三";//姓名 contact.gender="male";//性别 contact.note="售后服务";//注释 contact.save(onsuccess,onerror); } </script> </head> <body> <button onclick="createcontact();">create contact</button> </body> </html>
以上这篇使用phonegap创建联系人的实现方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。