How to track removeItem and setItem from localstorage?

  • 0
    developer.mozilla.org

    window.addEventListener('storage',function(){
    alert('session storage variable value changed');
    });


    This code sees changes when I enter them from the keyboard or delete them myself. However, when I do it through removeItem or setItem, it doesn't see anything.
    JavaScript Fiona Marshall, Jul 25, 2020

  • 2 Answers
  • 0
    It would seem - what could be easier than copying a piece of bourgeois text and translating it in Google translator, if you don't understand what is written?

    The StorageEvent is fired whenever a change is made to the Storage object. This won't work on the same page that is making the changes - it is really a way for other pages on the domain using the storage to sync any changes that are made. Pages on other domains can't access the same storage objects.


    Translation:

    The
    StorageEvent fires whenever changes are made to the Storage object. This won't work on the same page the changes are made on - it really is a way for other pages in the domain using the store to sync any changes made. Pages in other domains cannot access the same storage objects.
    Julian Russell

  • 0
    Just write your analog of seItem. Profit!
    Kira Wu

Your Answer
To place the code, please use CodePen or similar tool. Thanks you!