Example situation, having many pages opened with same domain name, in fact, it's very easy to use the idea for even totally different domain names. How? I'll write another document about it - but it IS simple.
The entire idea is based on a way that local network works, before explaining how it works, there is need to explain current techniques and theirs problems (we are not talking here about popups and its parents).
In general there are 4 ways of communication between browser windows:
- using window object (name property as far as I remember), this is very unsecure way, you cause other pages to be able to read that property, its also not working well for different instances. In my opinion should never be used for communication purpose.
- manipulating embeded frames in conjunction with domain property change and using same name of frame/popup - this is the way you access external embeded iframe knowing it exists and trying to open popup with that name will return reference to the iframe. This method doesnt work for all browsers and is very messy (probably you will always have initial moments of some crazy control popup appearing). The good thing about it is: direct access to your remote objects - you access them directly via frame, so thats a nice thing. There are also few other small problems with this solution (domain name limits, necessary extra files on server side etc. ... it is just a pain).
- Would be wonderful if new specifications for "postMessage" like methods was supported by all browsers, unfortunately - it doesnt and domain name limitations differs across browsers types (a bit annoying). Combining 2+3 would with pain construct solution for all browsers - but warning is: this will be a PAIN and remember that postMessage methods behave like network based communication.
- Cookies - old, supported by any browsers stuff. Cookies were used only for short messages (practically cookie max length is 4KB, some browsers handle more ... but most popular worst browsers does 4KB, so this is why it's "practically".
Cookies limitations for size in my opinion is the only problem, seems that other problems with it was implementation.
I used to face all of these issues and one evening I have properly got annoyed with current solutions state and I have written code that using cookies only allows to exchange communication with any browser window/frame/page instance.
Solution is simple, the difficulty was implementation.
I have emulated network messaging packets flow similar way as BNC networks work, as a packet I have used: COOKIE.
The cool thing about implementation is that one can easily change from cookie to something else shared and use it with BNCConnector (I named it from BNC networks model).
To test the lib simply check out:
http://theprivateland.com/bncconnector
http://theprivateland.com/bncconnector/docs.htm
There is some more details , I thing that docs page will be best as showing example of usage - simpler=better.
The connector will work on any browser version that uses javascript and cookies, including mobile devices etc.
The solution can be easy enchanced to enable communication even across different domains :-) Give me a shout if its worth adding it.