[html5] OnStorage Event

Jaikishan Jalan jai.ism at gmail.com
Thu May 6 10:21:21 PDT 2010


Thanks Ian.  Yes, it does work. I was checking it in wrong way in my event
handler. The following works

    function OnStorageHandler() {
        if (event.storageArea == localStorage) {
            alert("localstorage");
        } else {
            if (event.storageArea == sessionStorage) {
                alert("sessionStorage");
            }
        }
    }

On Wed, May 5, 2010 at 7:00 PM, Ian Hickson <ian at hixie.ch> wrote:

> On Wed, 5 May 2010, Jaikishan Jalan wrote:
> >
> > I understand that onstorage event will be invoked if setItem, removeItem
> > or clear is invoked on either sessionStorage object or localStorage
> > object. I am curious how can I determine which object has changed from
> > within the onstorage event handler. To be precise, is the function
> > called because localStorage object changed or sessionStorage object
> > changed. storageArea attribute to event object does not help.
>
> You should be able to compare the storageArea attribute of the event
> against the localStorage and sessionStorage objects.
>
> --
> Ian Hickson               U+1047E                )\._.,--....,'``.    fL
> http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
> Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'
>



-- 
Thanks,
Jaikishan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.whatwg.org/pipermail/help-whatwg.org/attachments/20100506/55f9c1fc/attachment-0002.htm>


More information about the Help mailing list