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?


 

 

 

 



C


Solution:-

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)

1

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

2

What is the correct HTML5 element for playing audio files?

3

What is the correct HTML5 element for playing video files?

4

In HTML5, onblur and onfocus are:

5

Which element is no longer supported in HTML5?

Comments