1

I have one main window and some child windows. My child window is creating by code behind.

 var newWindow = window.open(url, windowName, windowFeatures);

Also I need to add

 newWindow.document.onfocusout = this.windowOnUnload;

event to the child. My problem is that, when I need a POST action to this page I again recreate this child window with the same code stated above. But the onfocusout event is not firing. But first time it will fire. Also I am creating the child window is always with the same window name. Please help me finding a solution. Thank you

enter image description here

felix Antony
  • 1,450
  • 14
  • 28

1 Answers1

1

When you recareate the window, did you mean update its contents with an ajax call? or do you literally close it and then again call window. open, and finally wire the onfocusout event?

If the former is the case, then you will need to rewire the event to the new document that has been obtained using the AJAX call, as the whole document is changed and the previous event handlers for the previous document object are no longer relevant.

Update: could you post all the relevant code that you are using? This is how I can best help.

newWindow.document.onfocusout = this.windowOnUnload; doesn't seem to be the correct way to do what you need. I'm surprised it's working with you. Check this question: Is there a way to detect if a browser window is not currently active?

Community
  • 1
  • 1
Lzh
  • 3,585
  • 1
  • 22
  • 36