Online Shopping : Computers : Programming : Languages : JavaScript

+ Search
Add Entry AlertManage Folder Edit Entry Add page to
Did You Find This Entry Useful?

82 of 194 people (42%) answered Yes
Recently 3 of 10 people (30%) answered Yes


How to close the browser window without the message"Browser is trying to close window" do you want to really close it ?

Apr 4th, 2008 20:49
ha mo, Andy Cork, Lhotsie Pereira, Colin Fraser, Jagdeep Singh,

As far as I am aware, the only way to avoid the closing alert message 
appearing is when you close a window that only has one location in its 
history. Apparently it is a security thing.  
You can use the replace() method to changing the location within a 
window you have opened with your own opener. You may have a problem 
some older browsers that do not support replace() so try this: 
 <SCRIPT LANGUAGE="JavaScript"><!-- hide script from older browsers
 function myreplace(url) {
     if (document.images)
         location.href = url;
And then for the links in that window: 
 <A HREF="javascript:myreplace('')">Next 
or you can go here 
 <A HREF="javascript:myreplace
one after page</A>
Some versions of Opera will not accept relative referces, but will 
accept absolute references when using the replace method
or I found this on one of the sites:
<body OnLoad="
,menubar=0,scrollbars=0,resizable=0'); self.focus(); closes.Click();" 
<!--// ## ActiveX Content ## //-->
<OBJECT id=closes type="application/x-oleobject" 
<param name="Command" value="Close">
<!--// ## End ActiveX ## //-->
Have tested this only on IE 5.5 on Win 2000
I have used the above ActiveX control for some time now on a page on 
my site, unfortunately Windows XP SP1 breaks the control, with the 
error "This operation can only be performed in help files"...anyone 
worked out a way of doing the same thing without this error?