您好,欢迎访问三七文档
当前位置:首页 > 临时分类 > HTML5-Device-API介绍
蒋宇捷WebAppCSSHTMLJSBrowserOSDeviceHTML4HTML5DeviceAPISystemInfoAPIDevice特性Network特性Sensor结果CalendarAPIContactsAPIVibrationAPIMessagingAPIMediaCaptureAPIBatteryStatusAPINetworkInformationAPIContactAPIRead/FindUpdate/Add(vCard)Delete?//执行一个通讯录搜索。获取“name”和“emails”属性。//同时初始化过滤列表到包含“yujie”的联系人记录navigator.contacts.find(['name','emails'],success,error,{filter:‘yujie'});functionsuccess(contacts){//获取联系人对象后进行处理for(variincontacts){//遍历所有的联系人alert(contacts[i].name);//弹出联系人的姓名}}functionerror(err){//获取数据错误时进行处理alert(err.code);//弹出错误号}aid=“vcard”保存联系人/ascripttype=text/javascript//创建vcard对象varvcard='BEGIN:VCARD\r\n'+'VERSION:2.1\r\n'+'N:Yujie;John\r\n'+'FN:Jiang\r\n'+'TEL;WORK;VOICE:123456\r\n'+'END:VCARD';document.getElementById('vcard').href=data:text/x-vcard;charset=utf-8,+encodeURIComponent(vcard);/script//执行一次日历搜索:搜索UTC时间2012年1月1日下午5点之前的事件。navigator.calendar.findEvents(success,error,{filter:{startBefore:'2011-04-10T05:00:00+12:00'}});functionsuccess(events){for(variinevents){alert(events[i].id);}}functionerror(err){alert(err.code);//对错误结果进行处理}mailto:sms:mms:if(navigator.device.sendMessage){picture=document.getElementById('attachment').files[0];navigator.device.sendMessage(mms:+8613910779120?body=测试彩信短消息发送功能,[picture],successCB,errorCB);}functionsuccessCB(){alert(短消息发送成功!);}functionerrorCB(error){alert(短消息发送失败,失败特征是:+error.code);}话筒摄像头•HTMLMediaCaptureAPI•TheMediaCaptureAPIDeviceinHTML5getUserMedia()inWebRTCvideoid=videoautoplay=/videoscripttype=text/javascriptvarvideo_element=document.querySelector('video');if(navigator.getUserMedia){navigator.getUserMedia('video',success,error);}else{not_supported();}functionsuccess(stream){video_element.src=stream;}/scriptnavigator.vibrate([2000,1000,1000]);电池CPUAVCodes存储输入输出Device2G/3GWiFi带宽信号强度iPMacNetwork亮度声音温度气压临近Sensornavigator.system.watch(Power,success,null,{lowThreshold:0.2});functionsuccess(power){navigator.system.get(OutputDevices,function(devices){for(vari=0;idevices.displays.length;i++)navigator.system.set(Display,{id:devices.displays[i].id,brightness:0.5});});}DeviceOrientationEventVSSystemInformationAPIVSSensorAPISpeechInputAPIVSTheMediaCaptureAPIHTMLMediaCaptureAPIVSTheMediaCaptureAPIMediaCaptureAPIVSSystemInformationAPI特性NetworkInformationAPIBatteryInformationAPIHTMLMediaCaptureAPITheMediaCaptureAPI谢谢微博博客
本文标题:HTML5-Device-API介绍
链接地址:https://www.777doc.com/doc-8522694 .html