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.1



p = object.geolocation

Property values

Type: Object

A reference to a geolocation object.

Standards information


The geolocation property is only supported for webpages displayed in a Windows Store app using JavaScript. For more information, see Defining Document Compatibility.


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

<!DOCTYPE html>  
<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.";
  console.log( str );
<input type="button" onclick="show_islocationenabled()" 
   value="Is Geolocation supported?" />

See also




© 2014 Microsoft