android h5 保存通讯录,h5+调用系统通讯录

本文介绍了如何在H5中调用系统通讯录的步骤,通过JavaScript的plus contacts API获取用户联系人信息,并展示了相关的代码示例。文章还提供了错误处理和一个简单的示例列表展示。有兴趣的读者可以到作者的个人博客留言交流。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

h5+调用系统通讯录

发布时间:2018-03-15 10:09,

浏览次数:1259

Contacts Example

body,html{

width: 100%;

height: 80%;

font-size: 62.5%;

background: rgb(245,245,245);

}

*{

margin: 0;

padding: 0;

}

ul{

list-style: none;

}

a{

text-decoration: none;

}

.list-h{

width: 95%;

padding-left: 5%;

height: 3rem;

padding-top: 1rem;

padding-bottom: 1rem;

border-bottom: 1px solid #DDDDDD;

}

.list-h>p{

display: inline-block;

width: 3rem;

height: 3rem;

border-radius: 50%;

background: #29ACBA;

line-height: 3rem;

text-align: center;

color: #FFFFFF;

}

.list-h>h3{

width: 70%;

height: 3rem;

line-height: 3rem;

font-size: 1.4rem;

display: inline-block;

margin-left: 1rem;

}

// 监听plusready事件

document.addEventListener( "plusready", function(){

}, false );

function find(){

plus.contacts.getAddressBook(plus.contacts.ADDRESSBOOK_PHONE, function

(addressbook) {

addressbook.find(["displayName","phoneNumbers"],function(contacts){

var list="";

for(var i=0;i

if(contacts[i].phoneNumbers.length > 0){

var str=contacts[i].displayName.substr(contacts[i].displayName.length -2, 2);

list+="

class='list-h'>

"+str+"

"+contacts[i].displayName+"("+contacts[i].phoneNumbers[0].value+")"+"

";

}else{

}

}

$("body").append(list);

}, function () {

alert("error");

},{multiple:true});

},function(e){

alert("Get address book failed: " + e.message);

});

}

安丽

安丽(15545090181)

Find

有问题的话可以来本人个人博客留言:http://www.funtechstudy.com/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值