javascript - How to dynamically Update a text-box in a different page when the value changed using Local Storage? -
assume have 2 web pages. in page a, have button change value in local storage follows.
localstorage.setitem('key', key);
this key random string generated when button click. therefore each time when button clicked change localstorage value. in page b have textbox should dynamically change value when value of key in local storage changed.
it should happen when have opened 2 pages in 2 tabs in browser.
can use event listener that? if how implement ?
$(window).bind('storage', function (e) { console.log(e.originalevent.key, e.originalevent.newvalue); });
this trick
Comments
Post a Comment