<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
<script type="text/javascript" src="cordova.js"></script>
<title></title>
<script type="text/javascript" charset="utf-8">
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
window.addEventListener("listContacts", onlistContacts, false);
}
function onlistContacts() {
var options = new ContactFindOptions();
options.filter="";
options.multiple=true;
var fields = ["*"];
navigator.contacts.find(fields, onSuccess, onError, options);
}
function onSuccess(contacts) {
var ul = document.getElementById('contacts-list');
for (var i=0; i<contacts.length; i++)
{
var newLI = document.creatElement('li');
newLI.innerHTML = contacts[i].name.formatted;
ul.appendChild(newLI);
}
};
function onError(contactError) {
alert('onError!');
}
</script>
</head>
<body>
<h1 align="center" style="font-size: 50px"><u>Contacts</u></h1>
<ul id='contacts-list'></ul>
</body>
</html>
1 回答
- 1 回答
- 0 关注
- 935 浏览
添加回答
举报
0/150
提交
取消