I have a window in which on a button click I open a window. Now I want the child window to close when my parent window is closed. I wrote unload function for the parent window but then the line of code which I try to access the child window throws an error.
My child window is opened using this script from code behind:
"childWindow=window.open('MyPage.aspx,'ChildWindow','left=20, top=20, height=900, width=500,status= no, resizable= yes, scrollbars=yes, toolbar=no,location=no,menubar=yes'); childWindow.focus();"
In my parent unload function I am doing this:
$(window).unload(function () {
if ($(childWindow) != null)
$(childWindow).close();});
I guess it is some problem with the way I access the child window. But I dont know the right way to access the child window which was created by a script from code behind.