I'm creating a music playing website that loads a music player into a second window. The idea was that a user could browse the song library on the main page whilst being able to add songs to the second page's playlist.
This works fine when browsing the library using AJAX calls, in an ideal world however, the user would also be able to navigate to different pages in the site and still have access to the player.
I'm starting to think that is not possible? I've looked into storing the window reference (but they can't be serialised) and I've also tried resetting the child reference in the parent from the child window (does tha开发者_如何学Got make sense?).
I've settled on this solution: The child window calls a setChild
method on its opener every 100 ms. This works as I'd like, unfortunately it seems like a massive waste of resources, I'm left thinking that there must be a better way.
I've spotted a solution to a similar problem here:
Retrieve child window reference after refresh
but I can't find enough information about the applicationCache. Can I save the reference to the cache on unload and then reload it from a different page?
Thanks and sorry for the wall of text
I haven't verified this solution but you should be able to restore the reference by making a new call to window.open and providing an empty string for the url and specifying the same window name as the original call to window.open().
At the very least you could do 500ms instead of 100 and that should reduce your resource load considerably.
精彩评论