<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title></title> </head> <body> <div id="getarea">获取地理位置</div> <!-- geolocation对象还有2个方法, 1个是watchPosition(success,error,options); 重复获取地理位置 1个是clearWatch()用来清除前一次获取的位置信息 2个方法组合使用可以实现导航功能 Demo请在IE10以上版本测试! --> <script> window.onload=function(){ var getarea=document.getElementById('getarea'); getarea.onclick=function(){ //判断浏览器是否支持对象 if(navigator.geolocation){ //getCurrentPosition支持3个回调函数 //参数1的回调函数获取信息成功的函数 //返回coords.latitude纬度 coords.longitude经度 coords.altitude海拔 coords.accuracy位置精确度 //coords.altitudeAccuracy 位置海拔精确度 coords.heading 方向,正北开始计算 coords.speed 速度米/秒 coords.timestamp 响应的日期 //参数2的回调函数获取信息失败的函数 //code 错误代码 message是错误信息 //参数3的回调函数可以支持按照您的需求来设置一些参数 //enableHighAccuracy表示是否允许使用高精度 //timeout指定超时时间 //maximumAge是指缓存的时间 navigator.geolocation.getCurrentPosition(getsuccess,geterror,getoptions); } else{ console.log('浏览器不支持!'); } function getsuccess(objarea){ console.log('纬度是'+objarea.coords.latitude); console.log('经度是'+objarea.coords.longitude); console.log('海拔是'+objarea.coords.altitude); console.log('位置精确度'+objarea.coords.accuracy); console.log('海拔位置精确度'+objarea.coords.altitudeAccuracy); console.log('方向'+objarea.coords.heading); console.log('速度'+objarea.coords.speed); console.log('响应时间'+objarea.coords.timestamp); } function geterror(objarea){ console.log('错误代码'+objarea.code); console.log('错误信息'+objarea.message); } function getoptions(objarea){ objarea.timeout=1000; } } } </script> </body> </html>
苹果手机中禁止非HTTPS协议获取地址位置可以考虑使用微信jdk获取
WebSql的原理是浏览器集成了sqllite数据库,Js操作,浏览器协助完成,没有多复杂。<!-- 三个核心方法  ...
https://3gimg.qq.com/lightmap/v1/marker/index.html?marker=coord:37.6767600000,112.7297800000&key=TKUBZ-D24AF-GJ4JY-JDVM2-IBYKK-KEBCU&referer=p...
<!DOCTYPE html> <html> <head> <title>捕捉和冒泡</title> <meta charset="utf-8"> </head> <bo...
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title>获取mac地址</title> </head&g...
代码1:<!--代码开始--> <script src="http://lib.sinaapp.com/js/jquery/1.9.1/jquery-1.9.1.min.js"></script> <script>...
通过FormData对象可以组装一组用 XMLHttpRequest发送请求的键/值对。它可以更灵活方便的发送表单数据,因为可以独立于表单使用。如果你把表单的编码类型设置为multipart/form-data ,则通过FormData传输的数据格式和表单通过submit() 方法传输的数据格式相同...