ค้นหาเบอร์โทรใน Android ด้วย PhoneGap
<!DOCTYPE HTML> <html> <head> <meta name="viewport" content="width=320; user-scalable=no" /> <meta http-equiv="Content-type" content="text/html; charset=utf-8"> <title>PhoneGap</title> <script type="text/javascript" charset="utf-8" src="js/phonegap-1.3.0.js"></script> <script> function init(){ document.addEventListener("deviceready", startup); } function startup(){ document.getElementById("searchButton").addEventListener("click", handleSearch); } function handleSearch(e){ var search = document.getElementById("name").value; //What parts of the contact we will search var fields = ["displayName", "name"]; //Options for the search var options = new ContactFindOptions(); options.filter = search; options.multiple = true; document.getElementById("results").innerHTML="Searching..."; navigator.contacts.find(fields, contactSuccess, contactError, options); } function contactError(e){ document.getElementById("results").innerHTML=""; navigator.notification.alert("Sorry, an error was thrown!"); } function contactSuccess(results){ //No max, so we will default to only 10 var s = ""; for (var i = 0; i < Math.min(10, results.length); i++) { s += "<p>"+results[i].displayName+"</p>"; } document.getElementById("results").innerHTML=s; } </script> </head> <body onload="init()"> <h1>Contact Search</h1> <form> <input type="text" id="name"><br/> <input type="button" id="searchButton" value="Search"> <div id="results"></div> </form> </body> </html>
http://www.adobe.com/inspire/2012/02/combining-web-skills-phonegap-mobile-apps.html