Sometimes we need to open a small popup window and close the main (parent) window. Although you can achieve this by using a simple window.close(); or self.Close() method but when you try to close the parent window the security kicks in and asks that if you are sure that you want to close the parent window. You can however force the parent window to close without being asked.

Here is the small code (originally written by JL):

function OpenMainPage()

{

// open a new page

window.open('Page2.htm','Page2','toolbar=no,status=no,menubar=no,width=400,height=200');

// close the parent page

if(navigator.appName=='Microsoft Internet Explorer')

{this.focus();self.opener = this;self.close();}

else {

window.open('','_parent','');

window.close();

}

}

The code above will close the parent window and opens a small popup window.

Hope it helps!

AzamSharp