jQuery - cross window communication (popup to pick a file, no server side)

1.1k views Asked by At

I have an offine web page using jQuery. I would like it to read a file chosen by the user (or several files). I would like the file picker to be diplayed in another browser window, that would send the data back to the original window.

So:

  1. In the original windows there is a button "Choose files".
  2. New windows opens, which allows user to choose files in the form. User clicks "OK", the window is closed and somehow send the data about the choosen files to the original windows.
  3. The data that have been received are processed (and event is riggered).

What I manage to find is this: http://www.sfpeter.com/2008/03/communication-between-browser-windows-with-jquery-my-new-plugin/

However is seems rather oldish - do you know any newer and better solutions?

1

There are 1 answers

0
webnoob On

Check the bottom comment in the link you posted (posted by the author of the article):

I’m not using it myself anymore but may do a new revision if there’s demand for it. Since I wrote this plugin, a new HTML5 feature has been developed that would actually make this even easier: the postMessage API (link here). However I don’t know how well this feature is supported in older browsers like IE7 or IE8. I would rewrite my plugin to use the postMessage API by default but fall back on my old approach if necessary.

The syntax of this API is very similar to mine. Depending on what kind of browser support you need, the postMessage API may be all you need.

Maybe that will help.