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

The new HTML5 global attribute, "contenteditable" is used to:

2

In HTML5, contextmenu and spellcheck are:

3

In HTML5, you can embed SVG elements directly into an HTML page.

4

Graphics defined by SVG is in which format?

5

The <canvas> element in HTML5 is used to:

Comments