geolocation property
Gets a reference to a geolocation object, which reports the geographic location of the device running the application.
![]() ![]() |
Syntax
| JavaScript | |
|---|
Property values
Type: Object
A reference to a geolocation object.
Standards information
- Geolocation API Specification, Section 5.1
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
Show:

