Really Close Window in JavaScript?

B

Bill

As part of a website security system, I need to be able to close the active
window (without the user clicking on a link). Now, the javascript command

window.close()

gives a popup dialog warning that the window is being closed, & asks the
user if they want to close the window.

Is there a way to close the active window without getting a popup dialog?

THANKS!
 
T

Thomas A. Rowe

You would need load the application in a JavaScript created window, in order to close the window
with out a warning dialog, you can't close the user's browser/window.

--
==============================================
Thomas A. Rowe (Microsoft MVP - FrontPage)
WEBMASTER Resources(tm)

FrontPage Resources, WebCircle, MS KB Quick Links, etc.
==============================================
 
K

Kevin Spencer

The prompt is due to the "opener" property of the window being null. You can
fool the browser by setting the opener property to the window itself:

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

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Neither a follower
nor a lender be.
 
A

Andrew Murray

It will only say that if it is the *only* browser window open. it is not a
warning so much as an "information" box - telling you what is going to happen -
and it will do that only when you do the window.close() thing. Clicking File >
Close or the 'x' in the top right corner will not generate that message.
 
R

Ronx

If the window is not the only window open the warning message will also pop
up if the window has any history behind it, that is if the Forward and/or
Back buttons are active.
 
M

Murray

If you do this -

<script type="text/javascript">window.opener=self; self.close()</script>

I don't think you'll get the warning.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top