Online Shopping : Computers : Programming : Languages : JavaScript

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

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

Entry

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 
with 
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.replace(url);
     else
         location.href = url;
 }
 //--></SCRIPT>
And then for the links in that window: 
 <A HREF="javascript:myreplace('http://gohere.com/next.htm')">Next 
page</A>
or you can go here 
 <A HREF="javascript:myreplace
('http://gohere.com/theoneafter.htm')">The 
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="window.open
('colorassist.html','Start','toolbar=0,location=0,directories=0,status=
0
,menubar=0,scrollbars=0,resizable=0'); self.focus(); closes.Click();" 
onFocus="blur();">
<!--// ## ActiveX Content ## //-->
<OBJECT id=closes type="application/x-oleobject" 
classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11">
<param name="Command" value="Close">
</OBJECT>
<!--// ## End ActiveX ## //-->
</body>
Have tested this only on IE 5.5 on Win 2000
AndyC:
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?
http://www.businessian.com
http://www.computerstan.com
http://www.financestan.com
http://www.healthstan.com
http://www.internetstan.com
http://www.moneyenews.com
http://www.technologystan.com
http://www.zobab.com
http://www.healthinhealth.com