JavaScript Fetch API

The Fetch API interface allows web browser to make HTTP requests to web servers.

😀 No need for XMLHttpRequest anymore.

Browser Support

The numbers in the table specify the first browser versions that fully support Fetch API:

Chrome 42 Edge 14 Firefox 40 Safari 10.1 Opera 29
Apr 2015 Aug 2016 Aug 2015 Mar 2017 Apr 2015

Continue reading JavaScript Fetch API

Javascript Web Workers API

A web worker is a JavaScript running in the background, without affecting the performance of the page.

What is a Web Worker?

When executing scripts in an HTML page, the page becomes unresponsive until the script is finished.

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. Continue reading Javascript Web Workers API

Javascript Web Storage API

The Web Storage API is a simple syntax for storing and retrieving data in the browser. It is very easy to use:

Example

localStorage.setItem("name", "John Doe");
localStorage.getItem("name");

The Web Storage API is supported in all browsers:

Chrome IE/Edge Firefox Safari Opera
Yes Yes Yes Yes Yes

Continue reading Javascript Web Storage API

Javascript Web History API

The Web History API provides easy methods to access the windows.history object.

The window.history object contains the URLs (Web Sites) visited by the user.

The Web History API is supported in all browsers:

Chrome Edge Firefox Safari Opera
Yes Yes Yes Yes Yes

The History back() Method

The back() method loads the previous URL in the windows.history list.

It is the same as clicking the “back arrow” in your browser. Continue reading Javascript Web History API

Javascript Web APIs – Introduction

A Web API is a developer’s dream.

  • It can extend the functionality of the browser
  • It can greatly simplify complex functions
  • It can provide easy syntax to complex code

What is Web API?

API stands for Application Programming Interface.

A Web API is an application programming interface for the Web.

A Browser API can extend the functionality of a web browser.

A Server API can extend the functionality of a web server. Continue reading Javascript Web APIs – Introduction

JavaScript Cookies

Cookies let you store user information in web pages.

What are Cookies?

Cookies are data, stored in small text files, on your computer.

When a web server has sent a web page to a browser, the connection is shut down, and the server forgets everything about the user.

Cookies were invented to solve the problem “how to remember information about the user”:

  • When a user visits a web page, his/her name can be stored in a cookie.
  • Next time the user visits the page, the cookie “remembers” his/her name.

Cookies are saved in name-value pairs like:

username = John Doe

When a browser requests a web page from a server, cookies belonging to the page are added to the request. This way the server gets the necessary data to “remember” information about users. Continue reading JavaScript Cookies

JavaScript Timing Events

Timing Events

The window object allows execution of code at specified time intervals.

These time intervals are called timing events.

The two key methods to use with JavaScript are:

    • setTimeout(function, milliseconds)
      Executes a function, after waiting a specified number of milliseconds.

 

  • setInterval(function, milliseconds)
    Same as setTimeout(), but repeats the execution of the function continuously.

The setTimeout() and setInterval() are both methods of the HTML DOM Window object.

Continue reading JavaScript Timing Events

JavaScript Popup Boxes

JavaScript has three kind of popup boxes: Alert box, Confirm box, and Prompt box.

Alert Box

An alert box is often used if you want to make sure information comes through to the user.

When an alert box pops up, the user will have to click “OK” to proceed. Continue reading JavaScript Popup Boxes

JavaScript Window Navigator

The window.navigator object contains information about the visitor’s browser.

Window Navigator

The window.navigator object can be written without the window prefix.

Some examples:

  • navigator.cookieEnabled
  • navigator.appCodeName
  • navigator.platform

Continue reading JavaScript Window Navigator

JavaScript Window History

The window.history object contains the browsers history.

Window History

The window.history object can be written without the window prefix.

To protect the privacy of the users, there are limitations to how JavaScript can access this object.

Some methods:

  • history.back() – same as clicking back in the browser
  • history.forward() – same as clicking forward in the browser

Continue reading JavaScript Window History