通过HTML5 网页代码获取设备Sensor值
来源:互联网 发布:飞利浦呼吸机读卡软件 编辑:程序博客网 时间:2024/04/30 23:03
HTML5 Sensors
<!DOCTYPE html><html><head><meta charset="UTF-8" /><title>Web sensor</title></head><body><div id="error"></div><div id="light"></div><div id="locate"></div><div id="gsensor"></div><div id="gyro"></div><button onclick="getLightSensor()">光感测试</button><br><button onclick="getGsensor()">重力感应测试</button><br><button onclick="getLocation()">WiFi定位</button><button onclick="getGyro()">Gryo</button><button onclick="getCompassClb()">CompassClb</button><script>function getLightSensor() {var x=document.getElementById("light");var e=document.getElementById('error');window.addEventListener('devicelight', function(event) {x.innerHTML = 'Lux:' + Math.round(event.value) + 'lux';},true);}function getGsensor(){var x=document.getElementById("gsensor");window.addEventListener("devicemotion", function(event) {var eventacceleration = event.acceleration;x.innerHTML = "acceleration:<br>"+eventacceleration.x+"<br>"+eventacceleration.y+"<br>"+eventacceleration.z}, true);}function getGyro(){var x=document.getElementById("gyro");window.addEventListener("deviceorientation", function(event) {x.innerHTML = 'Gyro:<br>'event.alpha+'<br>'+event.beta+"<br>"+event.gamma+'<br>';}, true);}function getCompassClb(){window.addEventListener("compassneedscalibration", function(event) {alert('You need to calibrate you Compass');event.preventDefault();}, true);}</script><script>var x=document.getElementById("locate");function getLocation(){if (navigator.geolocation){navigator.geolocation.watchPosition(showPosition);}else{x.innerHTML="Geolocation is not supported by this browser.";}}function showPosition(position){x.innerHTML="Latitude: " + position.coords.latitude + "<br />Longitude: " + position.coords.longitude;}</script></body></html>
0 0
- 通过HTML5 网页代码获取设备Sensor值
- 通过java获取html网页代码
- U3D通过获取网页代码读取网页内容
- HTML5 Canvas 获取网页的像素值。
- php通过cookies获取远程网页的指定代码
- HTML5网页通过ajax跨域调用接口获取json数据并解析(一)
- HTML5网页页面坐标获取
- 使用C++ Builder XE5获取Sensor值之Light Sensor
- 网页时钟实现代码html5
- 通过html5获取地理位置信息
- WebClient获取网页代码
- android 获取网页代码
- 通过jericho获取网页编码
- 通过 WebBrowser 获取网页截图
- 通过 WebBrowser 获取网页截图
- 通过HttpURLConnection获取网页信息
- 通过距离感应器获取实际距离[FAQ04538][Sensor]java层获得P_sensor距离传感器当前真实值,不止0,1
- 获取Android 光感Sensor的值
- 如何关闭 xcode 8 疯狂的日志log输出
- SSH框架整合
- Go语言的beego框架中的orm中的Read函数使用
- ARM SWI软中断
- 框架 day75 涛涛商城项目easyUI异步tree,图片上传(nginx),KindEditor使用,商品添加
- 通过HTML5 网页代码获取设备Sensor值
- arttemplate+ajax 转 vue
- Android开发之Fragment的加载方式
- eclipce创建maven项目
- EM-LPC1768开发板原理图
- Spring(四)基于XML装配bean(实例化方式)
- python爬虫简单的抓页面图片并保存到本地
- View滑动冲突处理方法(外部拦截法、内部拦截法)
- overridePendingTransition函数