This version of the documentation is outdated!
Click here for the latest released version.
連絡人姓名
包含有關的不同種類的資訊 Contact
物件的名稱。
屬性
格式化: 該連絡人的完整名稱。() DOMString
家族: 連絡人的姓氏。() DOMString
givenName: 連絡人的名字。() DOMString
之間: 連絡人的中間名。() DOMString
honorificPrefix: 連絡人的首碼 (例如先生或博士) (DOMString)
honorificSuffix: 連絡人的尾碼 (如律師)。() DOMString
詳細資訊
ContactName
物件存儲的連絡人的名稱屬性。
支援的平臺
- Android 2.X
- 黑莓手機 WebWorks (OS 5.0 和更高)
- iOS
- Windows Phone 7 和 8
- Windows 8
快速的示例
function onSuccess(contacts) {
for (var i = 0; i < contacts.length; i++) {
alert("Formatted: " + contacts[i].name.formatted + "\n" +
"Family Name: " + contacts[i].name.familyName + "\n" +
"Given Name: " + contacts[i].name.givenName + "\n" +
"Middle Name: " + contacts[i].name.middleName + "\n" +
"Suffix: " + contacts[i].name.honorificSuffix + "\n" +
"Prefix: " + contacts[i].name.honorificSuffix);
}
};
function onError(contactError) {
alert('onError!');
};
var options = new ContactFindOptions();
options.filter = "";
filter = ["displayName", "name"];
navigator.contacts.find(filter, onSuccess, onError, options);
完整的示例
<!DOCTYPE html>
<html>
<head>
<title>Contact Example</title>
<script type="text/javascript" charset="utf-8" src="cordova.js"></script>
<script type="text/javascript" charset="utf-8">
// Wait for device API libraries to load
//
document.addEventListener("deviceready", onDeviceReady, false);
// device APIs are available
//
function onDeviceReady() {
var options = new ContactFindOptions();
options.filter="";
filter = ["displayName","name"];
navigator.contacts.find(filter, onSuccess, onError, options);
}
// onSuccess: Get a snapshot of the current contacts
//
function onSuccess(contacts) {
for (var i = 0; i < contacts.length; i ++) {
alert("Formatted: " + contacts[i].name.formatted + "\n" +
"Family Name: " + contacts[i].name.familyName + "\n" +
"Given Name: " + contacts[i].name.givenName + "\n" +
"Middle Name: " + contacts[i].name.middleName + "\n" +
"Suffix: " + contacts[i].name.honorificSuffix + "\n" +
"Prefix: " + contacts[i].name.honorificPrefix);
}
};
// onError: Failed to get the contacts
//
function onError(contactError) {
alert('onError!');
}
</script>
</head>
<body>
<h1>Example</h1>
<p>Find Contacts</p>
</body>
</html>
Android 的怪癖
- 格式化: 部分支援,和唯讀。 返回的串聯的
honorificPrefix
,givenName
,middleName
,familyName
,和honorificSuffix
.
黑莓手機 WebWorks (OS 5.0 和更高) 的怪癖
格式化: 部分支援。返回的串聯的黑莓手機名字和姓氏欄位。
家族: 支援。黑莓姓氏欄位中存儲。
givenName: 支援。黑莓名字欄位中存儲。
之間: 不受支援,返回
null
.honorificPrefix: 不受支援,返回
null
.honorificSuffix: 不受支援,返回
null
.
iOS 的怪癖
- 格式化: 部分支援。返回 iOS 複合名稱,但為唯讀。