473,473 Members | 2,272 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Close window without messagebox

Hello there

Is it possible to close a window without the messagebox coming up asking if
you really want to close the window?
Steven
Jul 20 '05 #1
9 2577
Only if it's not the last main browser window i.e not a popup.

I believe the answer is no.

Stu

"Steven Malcolm" <mi***********@ozemail.com.au> wrote in message
news:9A***************@nnrp1.ozemail.com.au...
Hello there

Is it possible to close a window without the messagebox coming up asking if you really want to close the window?
Steven

Jul 20 '05 #2

"Steven Malcolm" <mi***********@ozemail.com.au> wrote in message
news:9A***************@nnrp1.ozemail.com.au...
Hello there

Is it possible to close a window without the messagebox coming up asking if you really want to close the window?
Steven


Depends. Most browsers will not let you do this, IE (at least the more
recent versions) will. To do it in IE use:

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

IE seems to conclude that when a window has an opener it is not a top-level
window. This could break in any future version naturally but for now you can
save some users some trouble.

Silvio Bierman
Jul 20 '05 #3
On Fri, 5 Mar 2004 11:23:40 +0100, Silvio Bierman <sb******@idfix.nl>
wrote:

[snip]
IE seems to conclude that when a window has an opener it is not a
top-level window. This could break in any future version naturally
but for now you can save some users some trouble.


An intentionally introduced security vulnerability? What on Earth
possessed Microsoft to do this? JavaScript "developers" that complained
they couldn't close browser windows at their discretion, even when the
user might not want it to happen?

Mike

--
Michael Winter
M.******@blueyonder.co.invalid (replace ".invalid" with ".uk" to reply)
Jul 20 '05 #4
Michael Winter wrote:
Silvio Bierman wrote:
[snip]
IE seems to conclude that when a window has an opener it
is not a top-level window. This could break in any future
version naturally but for now you can save some users some
trouble.


An intentionally introduced security vulnerability? What
on Earth possessed Microsoft to do this? ...

<snip>

It is not so much introduced, more as yet unpatched. IE browsers (and a
fair number of others) have suffered from it for years. It doesn't get
publicised much on this group because rather than saving "users some
trouble", closing the users browser without their consent destroys
everything it continued, possibly including their browsing history,
session cookies, partly filled in form information, etc. So in reality,
predictably causing the user trouble. The people who ask the question
don't understand web browsers sufficiently to appreciate the harm such
an action can do, else they would never think such a thing was a god
idea.

The practical upshot of any wide dissemination of the hack, and its use
by inconsiderate web authors, will be that content-inserting proxies
will be distributed with built in filters to jump on either references
to the - window.close - method or the - opener - property. Moving
cross-window interaction even further into the realm of "too unreliable
to consider for Internet use". There are no shortage of javascript
authors who never consider the impact of their actions on users,
themselves or browser scripting as a task; whiteness the pop-up window.

Richard.
Jul 20 '05 #5
Michael Winter wrote:
On Fri, 5 Mar 2004 11:23:40 +0100, Silvio Bierman <sb******@idfix.nl>
wrote:

[snip]
IE seems to conclude that when a window has an opener it is not a
top-level window. This could break in any future version naturally
but for now you can save some users some trouble.

An intentionally introduced security vulnerability? What on Earth
possessed Microsoft to do this? JavaScript "developers" that complained
they couldn't close browser windows at their discretion, even when the
user might not want it to happen?

Mike


Search the archives for "The unconditional truth" and you will find a
partial list of browsers that have that "feature" and it is far from
limited to Microsoft.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/
Jul 20 '05 #6

Thanks for your answer, but excuse my ignorance, but I know next to
nothing about javascript.

How do I actually use

window.opener = window;
window.close();
Thanks
Steven
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #7
Thanks for your reply.

The reason I need to be able to close the web browser window is this.

I am writing a database at work which will work of a touchscreen at the
reception desk, and be used as a check-in/check-out system. Part of
this is that new visitors are taken through a short induction, which is
in the form of html pages(and I cannot change them to anything else),
and at the end of the presentation I need to be able to close the
browser and return to the database.

Thanks
Steven

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #8
Steven Malcolm wrote:
Thanks for your answer, but excuse my ignorance, but I know next to
nothing about javascript.

How do I actually use

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


From your other reply, you are working in an intranet environment and
as such, you have more control over what browser is used. If you can
modify the last .html in the intro course, then you add the above
snippet in the last page in a script block.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/
Jul 20 '05 #9
On Fri, 5 Mar 2004 06:40:50 -0000, "Stuart Palmer"
<st**************@ntlworld.com> wrote:
Only if it's not the last main browser window i.e not a popup.


Or _blank ...

--

find clausen
http://www.photopress.dk
Jul 20 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: John H. | last post by:
Hello I have some trouble in closing a window, Here is the problem: I develop a asp.net website use client side valiation <asp:CustomValidator id="CustomValidator1"...
3
by: s-galit | last post by:
hi, i have a module that created a form, and the messageBox is shown in the closing event , but when the im choosing the "cancel" button in the messageBox the messageBox and also the form is...
4
by: PawelR | last post by:
Hello group, In my apps I connection to SQL database. try { //connect to db } catch { MessageBox("Error Connect. Close Apps?","Sql Error",MessageBoxButtons.OKCancel,MessageBoxIcon.Error);
1
by: Alpha | last post by:
I have a Window based application that shows up still running in the task manager when I close it. It reaches the "this.close" statement and then it stops at the "}" at the section of the...
2
by: John H. | last post by:
Hello I have some trouble in closing a window, Here is the problem: I develop a asp.net website use client side valiation <asp:CustomValidator id="CustomValidator1"...
7
by: mg | last post by:
Once opening WebForm2 from WebForm1 using Response.Write("<script language='javascript'>window.open ('WebForm2.aspx','two','menubar=no');</script>"); how can I close WebForm1?
7
by: mg | last post by:
I need to first open WebForm2 from WebForm1 and then close WebForm1 without the end user having to press an OK button before the close can occur. For example, possibly ...
5
by: Nicola Farina | last post by:
Hi all, I've a window form application with 3 forms. I want to catch the security exception when users run this application from a network share, thus I've made this code (I've notice that...
4
by: RSH | last post by:
I am trying to figure out how I can trap the Closing Event that occurs when a user attempts to close the window by clicking on the red"X". I tried this code which I found online but nothing...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.