HTML5 Multiple choices

Total available count: 25
Subject - Web Development
Subsubject - HTML5

In HTML5, which method is used to get the current location of a user?







HTML5 Geolocation API lets you share your location with your favorite web sites. A JavaScript can capture your latitude and longitude and can be sent to the backend web servers and do fancy location-aware things like finding local businesses or showing your location on a map.

Geolocation API supports the latest browsers and mobile devices nowadays. The geolocation APIs work with a new property of the global navigator object ie. Geolocation object which can be created as follows,

var geolocation = navigator.geolocation;

A geolocation object is a service object that permits widgets to retrieve information about the geographic location of the website access or device.

Geolocation Methods:
The following methods provide by the geolocation object,

The getCurrentPosition() method: This method retrieves the current geographic location of the user or navigator.
The watchPosition() method: This method retrieves periodic updates about the current geographic location of the device.
The clearWatch() method: This method cancels an ongoing watchPosition call.

The following example is an easy and sample code to use any of the above methods,

function getLocation() {
 var geolocation = navigator.geolocation;
 geolocation.getCurrentPosition(showLocation, errorHandler);

Here showLocation and errorHandler are callback methods that would be used to get the actual position as explained in the next section and to handle errors if there is any.

Next 5 multiple choice(s)


Which attribute for <script> elements is no longer required in HTML5?


What is the correct HTML5 element for playing audio files?


What is the correct HTML5 element for playing video files?


In HTML5, onblur and onfocus are:


Which element is no longer supported in HTML5?