0

I am trying to capture events on localStorage using an event listener. As storage event listeners only fire if triggered from a page other than the active one, I need a dummy page with which to bind my listener that stays in the background. Thus any storage events triggered by what my user is doing get captured by the always open dummy page. Doing this:

  window.open("NewPage.aspx").blur();  //NewPage.aspx being my dummy page that begins listening for storage events on open
  window.focus();

...works on my desktop browser, or at least it does on Chrome. However, on webkit based browsers, NewPage.aspx opens as the focused page or as a popup that you must close to go back to using the site.

Anyone know how to open a window in the background on web kit based browsers?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
jmease
  • 2,507
  • 5
  • 49
  • 89
  • you could try adding focus to the main page, you should also give the window a handle name, like window.open("NewPage.aspx", "dummyPage") – david Nov 14 '11 at 18:57
  • I thought that's what window.focus() accomplished??? I am already doing that. – jmease Nov 14 '11 at 19:05

1 Answers1

1

A firefox setting since 4.0 has disabled pop unders. Mozilla support you can see if this solution for Firefox 4 works.

Community
  • 1
  • 1
epascarello
  • 204,599
  • 20
  • 195
  • 236
  • Well darn. Any suggestions on how to accomplish what I'm trying to get to then? – jmease Nov 14 '11 at 19:08
  • Tried the suggestion on jsfiddle and it still doesn't blur the new window. – jmease Nov 14 '11 at 20:10
  • Your answer to my question seems to be 100% correct. For anyone else with this exact problem, here is how I got around it. First, I used window.location = "NewPage.aspx" and then from there I did window.open("MainPage.aspx"). Thus making my main page the popup and therefore the focused window. On desktop browsers, this is not ideal. However, for the mobile browsers on the tablet we are using, this seems to do the trick. – jmease Nov 14 '11 at 22:54