Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3695902
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T04:40:27+00:00 2026-05-19T04:40:27+00:00

Further to this question , I’m getting a curious result when binding a function

  • 0

Further to this question, I’m getting a curious result when binding a function to the change event of the Storage object in Chrome 8.0.552.224.

The test:

<!DOCTYPE html>
<html>
  <head>
    <title>Chrome localStorage Test</title>
    <script type="text/javascript" >

      var handle_storage = function () {
        alert('storage event');
      };

      window.addEventListener("storage", handle_storage, false);

    </script>
  </head>
  <body>
    <button id="add" onclick="localStorage.setItem('a','test')">Add</button>
    <button id="clear" onclick="localStorage.clear()">Clear</button>
  </body>
</html>
  • Open up the page in two Chrome windows, one window with two tabs,
  • Click the ‘Add’ button

When I do this I get an alert box displayed on on the second tab and on the second window but not on the tab that invoked the event (the I clicked on). As I understand it I should see three alert boxes (one for each tab opened).

Is this a bug? Is anyone else getting this behaviour? If not what version are you running? Or have I just got this all completely wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T04:40:27+00:00Added an answer on May 19, 2026 at 4:40 am

    Update and final conlusion

    It turns out that the spec actually says that this is the desired behavior, therefore IE9’s implementation is broken.

    4.2 The sessionStorage attribute

    When the setItem(), removeItem(), and clear() methods are called on a Storage object x … if the methods did something, then in every HTMLDocument … [that is] associated with the same storage area, other than x, a storage event must be fired….

    So as we can see, the spec does do a really bad job at making it clear, that this is the specified behavior. That was the reason why Opera 10’s implementation was broken and it’s most likely also the reason why IE9’s implementation is broken.

    What do we learn from that? Always read every, single, word of the specification (especially if you’re implementing the stuff…).

    Old answer

    As you said the basic behavior here is "Invoke on all but the current page".

    There’s an old Chrome Bug Report from last July.

    As one can read there, Firefox has the same "issue". I’ve tested this with the latest nightly, still behaves the same way like in Chrome.

    Another test in Opera 11 shows that this must be some kind spec’ed behavior, since Opera 11 does the exact same thing but Opera 10 did fire events on all windows / tabs. Sadly the official changelogs for Opera 11 do not state any change for this behavior.

    Reading through the specification, nothing there states this behavior. The only thing I could find is:

    The storage event is fired when a storage area changes, as described in the previous two sections (for session storage, for local storage).

    When this happens, the user agent must queue a task to fire an event with the name storage, which does not bubble and is not cancelable, and which uses the StorageEvent interface, at each Window object whose Document object has a Storage object that is affected.

    Note: This includes Document objects that are not fully active, but events fired on those are ignored by the event loop until the Document becomes fully active again.

    Well, what does the Note mean?

    From another specification:

    A Document is said to be fully active when it is the active document of its browsing context, and either its browsing context is a top-level browsing context, or the Document through which that browsing context is nested is itself fully active.

    Doesn’t make sense? Yes. Does it help us in any way? No.

    So we (in the JavaScript Chatroom) poked on #whatwg to see what all of this is about, so far there has been no response. I’ll update my answer as soon as we get any response.

    To conclude for now

    Firefox, Chrome, Safari and Opera have the exact same behavior. That is, they do not fire on the tab / window that made the chance to localStorage.

    But IE9 Beta behaves like Opera 10, so it fires on all tabs / windows.

    Since the author of the localStorage spec works at Google in R&D, I hardly doubt Chrome would get this wrong. And since there are no Bugs on this over at Bugzilla and Opera changed the behavior in 11, it seems that this is the way it should work. Still no answer why it works this way and why IE9 behaves differently, but we’re still waiting for a response from #whatwg.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Further to this question: Algorithm for determining a file’s identity Recap : I'm looking
Further to this question I've got a supplementary problem. I've found a track with
I'm expanding further on this question . I currently have an asp.net hyperlink for
This is a further discussion on this question: Why is it still possible to
Further to this question here , I'm really interested in creating my own UITabBar,
(This question has been rewritten from an issue with NSTextView following some further research)
Further to my question on disabling validators using javascript - Disable ASP.NET validators with
Taking shs's question a step further... Why isn't all government sponsored software open source?
I'm quoting myself on a previous question I asked to further explain: I'm trying
Update: Thanks for the suggestions guys. After further research, I’ve reformulated the question here:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.