positionError object
Provides methods for obtaining information about an error that occurred while attempting to use the Geolocation API.
![]() |
Members
The positionError object has these types of members:
Properties
The positionError object has these properties.
| Property | Description |
|---|---|
|
Returns an integer value that indicates the type of error that occurred while trying to retrieve geographic information. | |
|
Gets an error message for debugging purposes. |
Standards information
There are no standards that apply here.
Remarks
The positionError object is passed as a parameter to the error callback function defined for the getCurrentPosition function and the watchPosition function.
Windows Internet Explorer 9. The geolocation object is only supported for webpages displayed in IE9 Standards mode. For more information, see Defining Document Compatibility.
Examples
The following example shows an error callback function. The object passed into the error parameter is a positionError object.
function errorCallback(error) { var message = ""; // Check for known errors switch (error.code) { case error.PERMISSION_DENIED: message = "This website does not have permission to use " + "the Geolocation API"; break; case error.POSITION_UNAVAILABLE: message = "The current position could not be determined."; break; case error.PERMISSION_DENIED_TIMEOUT: message = "The current position could not be determined " + "within the specified timeout period."; break; } // If it's an unknown error, build a message that includes // information that helps identify the situation, so that // the error handler can be updated. if (message == "") { var strErrorCode = error.code.toString(); message = "The position could not be determined due to " + "an unknown error (Code: " + strErrorCode + ")."; } console.log(message); }
