2

I am creating a web page that offers the user the ability to "undock" a control into a new browser window. When the user selects a value in the new window, I need to have the new page pass data to the parent page and update some information on the screen. Basically, I need to keep the data displayed in sync. I am using jQuery and AJAX to avoid any postbacks and I would want to do the same for this. For example: The user does a search for "foo" on parent page and wants to see the results in a larger format. He clicks the "undock" button and larger window opens with the search results. The user selects a value from the child window and the parent window is updated as well. I would think I could accomplish this with AJAX but have yet to find a good post explaining it. Does anyone know how this can be done?

Also, if the child windows gets closed and I don't capture the close because of a browser crash, is there a way the parent can check to see if the child is still there?

Thanks!

Dave_in_Raleigh
  • 53
  • 1
  • 11
  • possible duplicate of [Can I pass a JavaScript variable to another browser window?](http://stackoverflow.com/questions/87359/can-i-pass-a-javascript-variable-to-another-browser-window) – NotMe Feb 21 '12 at 15:10
  • It does talk about using the window.opener but I was wondering if there is a way via AJAX. – Dave_in_Raleigh Feb 21 '12 at 18:03
  • Ajax is simply a way for a browser to communicate with a server and receive a response *without doing a full post back*... At it's heart, it is javascript. So I'm not entirely sure what you mean by "via AJAX" – NotMe Feb 22 '12 at 00:04
  • I was thinking there was some way to use AJAX to post data from one page to the other. I played with the opener and found I can invoke a click() event on a control in the parent page from the child. I think that will get me where I need to be for my current task. I also found that the object returned from the window.open has a property “closed” I can use to see if the child was closed. – Dave_in_Raleigh Feb 22 '12 at 01:23

4 Answers4

0

you could try using socket.io, but it might be overkill for your scenario...

mindandmedia
  • 6,800
  • 1
  • 24
  • 33
0

Can't you use window.parent from the child window?

smitchelluk
  • 172
  • 1
  • 3
  • 13
0

To do your undock, are you using window.open? You can use window.opener to communicate between two windows: http://www.w3schools.com/jsref/prop_win_opener.asp

Rusty Divine
  • 3,462
  • 1
  • 21
  • 15