Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

close window without message 5

Status
Not open for further replies.

kvoguy

IS-IT--Management
Nov 15, 2002
34
BE
I try to close a browser window but I always get this stupid alert Are you sure you want to close the browser.

Is there a possible way to avoid this alertbox?

thanks in advance!
 
Hi kvoguy
Try this:

Code:
<html>
<head>
<script>
function bye() {
self.opener = this;
self.close()
}
</script>
</head>
<body>
<a href=&quot;JavaScript: bye()&quot;>Bye bye</a>
</body>
</html>
Hope I helped / Thanks for helping
if ((x<10&&y<10) &&(((parseInt(x.toString()+y.toString())-x-y)%9)!=0)){ alert(&quot;I'm a monkey's uncle&quot;); }
 
No.

This is not allowed for security reasons. You can only close windows you have opened with the window.open() method.

RKM

 
ok thank you rkmarcks. I also tried your method, Helltel but couldn't make it works.

thanks
 
rkmarcks
That code I supplied works, even with IE6 with SP1 installed, which tightened security.
Try it. [bigsmile]

Hope I helped / Thanks for helping
if ((x<10&&y<10) &&(((parseInt(x.toString()+y.toString())-x-y)%9)!=0)){ alert(&quot;I'm a monkey's uncle&quot;); }
 
Great timing, as ever. Must have posted at the same time.
I just tried my code again, with IE6 & SP1, NN4.7 & NN7. It worked a treat.
What's happening when you try it kvoguy? Hope I helped / Thanks for helping
if ((x<10&&y<10) &&(((parseInt(x.toString()+y.toString())-x-y)%9)!=0)){ alert(&quot;I'm a monkey's uncle&quot;); }
 
Ah, one of those bits of code that you pick up from somewhere else, but thanks!
[wiggle] Hope I helped / Thanks for helping
if ((x<10&&y<10) &&(((parseInt(x.toString()+y.toString())-x-y)%9)!=0)){ alert(&quot;I'm a monkey's uncle&quot;); }
 
helltel -

&quot;self.opener = this&quot;

I always assumed that self.opener was read-only! This is great! A star for you! -----------------------------------------------------------------
&quot;The difference between 'involvement' and 'commitment' is like an eggs-and-ham breakfast: the chicken was 'involved' - the pig was 'committed'.&quot;
- unknown

mikewolf@tst-us.com
 
well, when I'm clicking on a link a new window starts up. When I click on this link I also want to close the window in which I can see the link. So the only thing I would like to see then is the new window I opened with the first link. This window is 640*480. But when my first browser window is still viewable I see two windows, and this I want to aviod with closing the first window. but then I always get the alertbox.
 
A star from me too. Great one!!! [thumbsup2]
relax.gif

 
Bye script worked great, but just thought I would mention that attempting to preview this script in HTML-Kit preview window will crash HTML-Kit if you then try to go back to page containing script after clicking &quot;Bye&quot; in the preview window. The error msg will say&quot; &quot;Could Not Obtain OLE Control Window Handle&quot; and HTML-Kit will then be frozen.
 
In Mozilla (and I mean in other Gecko like browsers) user can disable construction:

window.opener=self;
self.close();

If you edit all.js in row:
pref(&quot;capability.policy.default.Window.close&quot;, &quot;allAccess&quot;);
and change value to noAccess. After will be in javascript console Permission denied, if you call method window.close()

BTW:
In Mozilla 1.0 and 1.1 is small bug with window.close(). If window is not open from window.open() method, then you can close it via window.close() without window.opener=self.

Coracal
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top