Communication between tabs/windows with same origin [duplicate]

I’m sticking to the shared local data solution mentioned in the question using localStorage. It seems to be the best solution in terms of reliability, performance, and browser compatibility. localStorage is implemented in all modern browsers. The storage event fires when other tabs makes changes to localStorage. This is quite handy for communication purposes. References … Read more

localStorage is not defined (Angular Universal)

These steps resolved my issue: Step 1: Run this command: npm i localstorage-polyfill –save Step 2: Add these two lines in server.ts file: import ‘localstorage-polyfill’ global[‘localStorage’] = localStorage; Once you are done, run build command (eg: npm run build:serverless) All set now. Start the server again and you can see the issue is resolved. Note: … Read more

localStorage access from local file

When you are opening the files locally, i.e. using the file:// protocol, as of now the browsers can not determine what is “same domain” so every file is considered a separate domain. Thus you can not use localStorage when you’re opening the files. Here is some more information on the problem in FireFox: https://bugzilla.mozilla.org/show_bug.cgi?id=507361 . … Read more

How to find the size of localStorage

Execute this snippet in JavaScript console (one line version): var _lsTotal=0,_xLen,_x;for(_x in localStorage){ if(!localStorage.hasOwnProperty(_x)){continue;} _xLen= ((localStorage[_x].length + _x.length)* 2);_lsTotal+=_xLen; console.log(_x.substr(0,50)+” = “+ (_xLen/1024).toFixed(2)+” KB”)};console.log(“Total = ” + (_lsTotal / 1024).toFixed(2) + ” KB”); The same code in multiple lines for reading sake var _lsTotal = 0, _xLen, _x; for (_x in localStorage) { if (!localStorage.hasOwnProperty(_x)) … Read more