Answer the question
In order to leave comments, you need to log in
Emulating an event from local storage works in Chrome, but doesn't work in Firefox - what's wrong?
The event listener for local storage fires when there is a change in local storage on other tabs and does not fire in the current tab, so it was decided to emulate the event. The following code works in Chrome:
var e = document.createEvent( 'StorageEvent' );
e.initStorageEvent('storage');
window.dispatchEvent(e);
e.initStorageEvent('storage', true, false, storage_cell, 0, 0);
Answer the question
In order to leave comments, you need to log in
The correct construction of the initStorageEvent function is:
void initStorageEvent(
in DOMString typeArg,
in boolean canBubbleArg,
in boolean cancelableArg,
in DOMString keyArg,
in DOMString oldValueArg,
in DOMString newValueArg,
in DOMString urlArg,
in nsIDOMStorage storageAreaArg
);
var e = document.createEvent( 'StorageEvent' );
e.initStorageEvent('storage', true, false, 'key', 'oldValue', 'newValue', location.href, window.localStorage);
window.dispatchEvent(e);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question