EN
Este contenido no se encuentra disponible en su idioma, pero aquí tiene la versión en inglés.

geolocation property

Gets a reference to a geolocation object, which reports the geographic location of the device running the application.

Geolocation API Specification, Section 5.1Internet Explorer 9

Syntax

JavaScript

p = object.geolocation

Property values

Type: Object

A reference to a geolocation object.

Standards information

Remarks

Windows Internet Explorer 9. The geolocation property is only supported for webpages displayed in IE9 Standards mode. For more information, see Defining Document Compatibility.

Examples

The following example shows how to determine whether or not the geolocation object is supported before attempting to access it.


<!DOCTYPE html>  
<html>
<head>
<title>Geolocation example: Checking for geolocation support</title>
<meta http-equiv="X-UA-Compatible" context="IE=9">
<script type="text/javascript"> 
function show_islocationenabled()
{
  // Default to failure condition.
  var str = "No, geolocation is not supported.";  
  if (window.navigator.geolocation) {
    str = "Yes, geolocation is supported.";
  }
  alert( str );
}
 
</script>
</head>
<body>
<input type="button" onclick="show_islocationenabled()" 
   value="Is Geolocation supported?" />
</body>
</html>

See also

navigator

 

 

Mostrar:
© 2014 Microsoft