Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • NW.js Essentials
  • Toc
  • feedback
NW.js Essentials

NW.js Essentials

By : Benoit
4.8 (5)
close
NW.js Essentials

NW.js Essentials

4.8 (5)
By: Benoit

Overview of this book

If you are an experienced Node.js developer who wants to create amazing desktop applications using NW.js, this is the book for you. Prior knowledge of HTML5, jQuery, and CSS is assumed.
Table of Contents (11 chapters)
close
10
Index

XMLHttpRequest and BLOBs

The one thing you should remember when dealing with XMLHttpRequest on NW.js applications is that local files, called through the file:// or app:// protocols, return 0 as the HTTP response.

var xhr = new XMLHttpRequest(), blob;
xhr.open('GET', 'myBlob.jpg', true);
xhr.responseType = 'blob';
xhr.addEventListener('load', function () {
  if (xhr.status !== 200) return;
  blob = xhr.response;
  // Do something with blob
}, false);
xhr.send();

In the preceding example, we try to get a BLOB ( which, in our case, is an image), but the code will stop when checking for xhr.status !== 200 as the returned status for local files will indeed be 0. I take this opportunity to show you how to store BLOBs in an IndexedDB object store:

var xhr = new XMLHttpRequest(), blob;
xhr.open('GET', 'maggieAvatar.jpg', true);
xhr.responseType = 'blob';
xhr.addEventListener('load', function () {
  maggieAvatar = xhr...
bookmark search playlist font-size

Change the font size

margin-width

Change margin width

day-mode

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Delete Bookmark

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete