HTML5 / JS storage event handler



Storage event handlers only fire if the storage event triggered by another window. You can try to run the following code:

// event handler
window.addEventListener('storage', storageEventHandlerFunc, false);

function storageEventHandlerFunc(evt) {
   alert("Storage event called key: " + event.key );
   switch(event.key){
      case 'one':
      case 'two': batteryDCMeter(); break;
      case 'extPowerOn': rechargeBattery(); break;
   }
}
sessionStorage.setItem("someKey", "someValue");

Advertisements