tags:

views:

59

answers:

1

Hi All,

I open a pop-up window using following code in main.html

function openwindow(url)
{
    window.open(url, "mywindow","location=1,status=1,scrollbars=1,resizable=no,width=650,height=650");
}

<a href="javascript: openwindow('/chats/chat?url=http%3A%2F%2Flocalhost%3A3001')">Open</a>

In My child.html i used

function closewindow()
{
    self.close();
}

function closeIt()
{
    return "Your chat will be terminated. Are you sure?"
}

<a href="javascript:void(0)" onclick="closewindow();">Close Window< /a > &nbsp; &nbsp; 

When i click on close window it gize me alert message that i given on event onbeforeunload but it not close the window when i click on Ok.Also this happens only in I.E. & working fine in mozilla, netscape, safari. I checked it on IE6 & IE8

Any help is Appreciated.

Regards,

Salil Gaikwad

+2  A: 

This is an issue from quite awhile. You can try this

< a href="javascript:window.opener='x';window.close();">Close< /a>

but it will close the window without the prompt for closing the window.

Another solution is:

function closeWindow() {

     //var browserName = navigator.appName;

     //var browserVer = parseInt(navigator.appVersion);

     var ie7 = (document.all && !window.opera && window.XMLHttpRequest) ? true : false;  

     if (ie7)

           {    

           //This method is required to close a window without any prompt for IE7

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

           window.close();

           }

     else

           {

           //This method is required to close a window without any prompt for IE6

           this.focus();

           self.opener = this;

           self.close();

           }

}

but as far as i know, the window.prompt method in IE7 is blocked. You can have a look THIS thread where this issue is discussed.

o15a3d4l11s2
> > < a href="javascript:window.opener='x';window.close();">Close< /a>This is not worling properly in mozilla only so i don't check it on IE.
Salil