views:

21

answers:

1

Hello,

I am designing a web site that plays music. The music player itself will be in a separate window along with the now playing list. I want to be able to refresh the now playing list when a new song is added to it from the main window. Essentially I need to figure out how to communicate between the two windows. I was only able to find one plugin on line that defines the player page as a child of the main page but then this reference would be lost after the parent page i.e my main page was refreshed. So this was not very useful to me and I'm kinda lost atm. Any help is greatly appreciated

PS: here is the link to that plugin (http://www.sfpeter.com/2008/03/13/communication-between-browser-windows-with-jquery-my-new-plugin/)

+1  A: 

Once that parent page is refreshed, you're done - because its not the same page anymore. You can't arbitrarily do things to one window from another that have no relation.

The only potential workaround is to store whatever information the child window needs on the server, and then use ajax polling to check for updates very ... 30seconds? 10 seconds? However often seems best for your application.

Erik
is there no other way to communicate between two windows? maybe if the pages had ids of some sort? but how would i do this?
Shanon
There is no other way to do so. If it were possible, imagine the implications. Bad hacker a pops up a tiny window - behind your main window - when you inadvertently visit his site. Then his little hidden window screws with your webpages until you notice it ... if you notice it.
Erik
yeah...that makes sense. when you say store information on the server do you mean a database?
Shanon
Or a text file, or ... whatever you need. I really don't know enough about your app to determine that.
Erik
oh okay...erm sorry for the bombardment of questions but do you know if there is any way to check if my player window is open. As is check if the player is already running in a separate window...so essentially check if a certain webpage is open.
Shanon
When you open the window, assign the reference to a variable: `win = window.open("http://www.example.com/","myWin");` then you can check `if(win.open) { // the window you opened before exists still }`
Erik