[thelist] Javascript:self.close() w/out Warning

Abdullah Shaikh Abdullah.Shaikh at mail.com
Thu Jan 30 10:39:08 CST 2003


Javascript won't give a message on window.close() if the window was opened
via javascript.  This is tracked via the parent property.

You can fake this out, by giving the parent property a value.

For example.. if you use...

              window.parent = true

then

              self.close()

will think that the window was opened by a parent window, and won't give you
the warning.  voila.

( i am not sure of the exact syntax of the above... but that's the general
idea )


- Abdullah

-----------------------
abdullah shaikh
technical director
uxDesignGroup


----- Original Message -----
From: "shawn allen" <shawn at alterior.net>
To: <thelist at lists.evolt.org>
Sent: Wednesday, January 29, 2003 3:01 PM
Subject: Re: [thelist] Javascript:self.close() w/out Warning


> quoth Rob Smith:
> > Is there a way to close the browser window with Javascript that
> > doesn't prompt the user?
>
> It's totally UA-dependant. Most browsers only allow it if the
> window.close() is triggered via a user action (such as clicking on a
> button or link). It's pretty nasty to close a user's window without
> their approval, dontcha think? :)
>
> --
> shawn allen
>   mailto://shawn@alterior.net
>   phone://415.577.3961
>   http://alterior.net
>   aim://shawnpallen
>
>



More information about the thelist mailing list