HTML 5 GEOLOCATION API

  • HTML5 Geolocation API
  • It is used to Locate the User’s Position
  • The HTML Geolocation API is used to get the geographical position of a user.
  • Since this can compromise privacy,
  • User will have to give permission in order to get his/her location

We use navigator.geolocation.getCurrentPosition to get the user location

2) HTML 5 Drag and Drop

  • You can “grab” an object and drag it to a different location.
  • Any element in HTML 5 can be drag and drop
  • First make Draggable attribute to true of the html element
  • <img draggable=”true”>
  • There are two things :
  • What to drag Where to drag

Example of Drag and Drop:

<div id=”divdrop” ondrop=”dropevtn(event)” ondragover=”allowDrop(event)”></div>

<img id=”drag1″ src=”img_logo.gif” draggable=”true”
ondragstart=”drag(event)” width=”336″ height=”69″>

3) HTML 5 Web Storage

  • It is used to store the user data locally
  • Earlier we use cookies to store data in which we can only store limited amount of data
  • With web storage large amount of data can be stored without any performance effect and also it is more secure
  • 5mb of data can be stored
  • Cookies can store very less data

Two types of Web Storage:

  • window.localStorage- stores data with no expiration date
  • window.sessionStorage- stores data for one session (data is lost when the browser tab is closed)
  • Store item in localstorage
  • localStorage.setItem(“subject”,“maths”);
  • Retrieve items from local storage
  • localStorage.getItem(“subject”);

4) Web Workers in HTML 5:

  • A web worker is a JavaScript that runs in the background independently of other scripts, without affecting the performance of the page.
  • You can continue to do whatever you want: clicking, selecting things, etc., while the web worker runs in the background.

Example :

w = new Worker(“latest_workers.js”);

5) Server Side Events :

  • To update the page automatically from the server
  • The server sends messages automatically to update the page
  • One way messaging

 

 

154total visits,2visits today