定义和用法
- Página anterior cookieEnabled
- Página siguiente javaEnabled()
- Volver a la capa superior Window Navigator
属性返回可用于定位用户位置的
属性仅在用户批准后才可用。
Geolocation 对象 。属性是只读的。
属性仅在用户批准后才可用。
属性仅在安全上下文 (HTTPS) 中可用。
属性仅在用户批准后才可用。
geolocation
属性仅在用户批准后才可用。
注释:
对于具有 GPS 的设备(例如智能手机),地理位置要准确得多。另请参阅:
HTML5 Gelocation 教程
获取用户所在位置的经纬度:
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showPosition); else { } document.getElementById("demo").innerHTML = "Geolocation is not supported by this browser."; } function showPosition(position) { document.getElementById("demo").innerHTML = "Latitud: " + position.coords.latitude + "Longitud: " + position.coords.longitude; }
语法
navigator.geolocation
返回值
类型 | 描述 |
---|---|
对象 | 对 Geolocation 对象的引用。 |
浏览器支持
所有浏览器都支持 navigator.geolocation
:
Chrome | IE | Edge | Firefox | Safari | Opera |
---|---|---|---|---|---|
Chrome | IE | Edge | Firefox | Safari | Opera |
Soporte | Soporte | Soporte | Soporte | Soporte | Soporte |
- Página anterior cookieEnabled
- Página siguiente javaEnabled()
- Volver a la capa superior Window Navigator