473,406 Members | 2,343 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

close current window using window.close()

Hi,
When I want to close the current window using window.close() in IE6.0,
there will be a confirm box that: The web page you are viewing is trying
to close the window. Do you want to close this window?
I have to click yes to close the window.
How can I close the current window directly without this dialog box?

Thank you.
Sep 1 '05 #1
10 37961
Hope this helps:

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

..Andrew

Sep 1 '05 #2
This alert occurs only if there is only one window and cannot be
switched off.

Sep 1 '05 #3
Are you sure?
I guess it could be security-dependent, but the approach is not clear
enough.

The notorious code below does not work in Firefox :))

==========
<html>
<body onclick="alert('ooops'); window.opener=self; window.close();">
Click this page and window.close() is called.
</body>
</html>
=========

Nevertheless, I've checked it in Opera and IE, both succeeded.

Sep 1 '05 #4
closing popup windows (child windows) is acceptable, but the content
controlling the browser is not really good web practice.

I can think of instances when this would be helpful, but you should not
depend on it. Especially as the users may not have javascript, ot they
could have disabled it.

Ian
www.boan-design.co.uk

Sep 1 '05 #5
an********@gmail.com wrote:
Hope this helps:

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

.Andrew


Ok, this works for me
I only want it to work in IE, and I'll use other method for firefox

thanks Andrew and andreister
thanks all
Sep 1 '05 #6
Shang Wenbin wrote :
Hi,
When I want to close the current window using window.close() in IE6.0,
there will be a confirm box that: The web page you are viewing is trying
to close the window. Do you want to close this window?
I have to click yes to close the window.
How can I close the current window directly without this dialog box?

Thank you.


1st question in the FAQ on window.open():
http://developer.mozilla.org/en/docs...indow.open#FAQ

Gérard
--
remove blah to email me
Sep 1 '05 #7
ewosch said the following on 9/1/2005 3:44 AM:
This alert occurs only if there is only one window and cannot be
switched off.


That is far from the truth.

It does work if there are more than one window.
It *can* be switched off.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Sep 1 '05 #8
Randy Webb wrote :
ewosch said the following on 9/1/2005 3:44 AM:
This alert occurs only if there is only one window and cannot be
switched off.

That is far from the truth.

It does work if there are more than one window.
It *can* be switched off.


That's is already mentioned in MSDN documentation too. People way
over-want to kill opener windows but this goes against the best
interests of the users. Expect MSIE 7 to put an end to all this (wink)
and expect your scripts to fail closing such IE 7 windows. Mozilla-based
browsers already deny the capability to close such windows; reasonable
and responsible web designers don't try to close non-script-initiated
windows.

Gérard
--
remove blah to email me
Sep 1 '05 #9
Gérard Talbot said the following on 9/1/2005 12:54 PM:
Randy Webb wrote :
ewosch said the following on 9/1/2005 3:44 AM:
This alert occurs only if there is only one window and cannot be
switched off.
That is far from the truth.

It does work if there are more than one window.
It *can* be switched off.


That's is already mentioned in MSDN documentation too.


Where?

People way over-want to kill opener windows but this goes against the best
interests of the users.
That depends on the user I guess.
Expect MSIE 7 to put an end to all this (wink) and expect your scripts
to fail closing such IE 7 windows.
Somehow, I doubt it but would be totally shocked if it does. Considering
that IE has had that bug since IE5 or so, and it hasn't been fixed
through 3 versions, I don't see them fixing it now. That would require
MS to admit they had flawed software and actually fix it.
Mozilla-based browsers already deny the capability to close such windows;
Don't bet on it.
reasonable and responsible web designers don't try to close
non-script-initiated windows.


"reasonable and responsible web designers" don't use secondary windows,
so they have no need to close superficial windows.....
--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Sep 1 '05 #10
Randy Webb wrote :
Gérard Talbot said the following on 9/1/2005 12:54 PM:
Randy Webb wrote :
ewosch said the following on 9/1/2005 3:44 AM:

This alert occurs only if there is only one window and cannot be
switched off.


That is far from the truth.

It does work if there are more than one window.
It *can* be switched off.

That's is already mentioned in MSDN documentation too.

Where?


"Using script to close the last running instance of Microsoft Internet
Explorer also opens the confirmation dialog box."
http://msdn.microsoft.com/workshop/a...asp?frame=true
People way over-want to kill opener windows but this goes against the
best
interests of the users.

That depends on the user I guess.


I make a general rule, a generalization if you prefer, from this.
Any/every window has a system command close [x] button on the titlebar.
So why do scripters need to provide me with links, buttons, etc.. to
close that window. If I can open a new window on my own, I certainly can
close a secondary window on my own. Same thing with closing the internet
connection, shutting down the PC, closing the tv, etc.. I do not need
any additional, extra help in managing (open, resize, move and close)
windows which should be under my complete and entire control to begin
with. Browser manufacturers (Mozilla, Opera, Microsoft, Safari,
Konqueror, etc) understand such perspective and agree with it and they
are providing users with veto powers over script methods like open(),
resizeTo, moveTo, resizeBy, resizeTo, close, etc..
Expect MSIE 7 to put an end to all this (wink) and expect your scripts
to fail closing such IE 7 windows.

Somehow, I doubt it but would be totally shocked if it does. Considering
that IE has had that bug since IE5 or so, and it hasn't been fixed
through 3 versions, I don't see them fixing it now. That would require
MS to admit they had flawed software and actually fix it.


They can fix the bug without admitting anything seriously detrimental
too; security is a concern for all browser manufacturers and for
web-aware software makers. I created a page back 1-2 years ago with your
own data, Randy:

http://www.gtalbot.org/BrowserBugsSe...penedByJS.html

and then posted a request (see/search for: "opener property should be a
read-only property") in that sense at:

http://channel9.msdn.com/wiki/defaul...plorerSecurity

I also made sure Opera dev. is aware of this close() issue.
Mozilla-based browsers already deny the capability to close such
windows;

Don't bet on it.


Current Mozilla-based browsers do deny the capability to close such windows.
The default setting of dom.allow_scripts_to_close_windows in
about:config is false.

reasonable and responsible web designers don't try to close
non-script-initiated windows.

"reasonable and responsible web designers" don't use secondary windows,
so they have no need to close superficial windows.....


I would add one nuance to such statement but I'd rather not since I
fully (general rule) support this opinion.

Gérard
--
remove blah to email me
Sep 2 '05 #11

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

Similar topics

3
by: Bernd Liebermann | last post by:
Hi, I'm trying to change the content of an existing window from a second window using window.open(). This works fine in Netscape 7, but IE 6.0 returns an error, saying there's an invalid...
1
by: gopal srinivasan | last post by:
I need to know how to close a parent modal window when child modal window opens, also i need to know the syntax for writing document on the modal window on the fly, like what we do in case of...
2
by: mamin | last post by:
Hi, I need to send a file to a client and then close current window. My code looks as follows: Response.ContentType="application/bmp"; Response.AppendHeader("","attachment; filename=\"" +...
3
by: dibakar | last post by:
Hello I want to open a window using Window.showModalDialog once i click inside of a TextBox.And that window need to come just under the TextBox,so that it seems to a same control. So,what...
7
by: tapanreddy | last post by:
I am looking to perform an action when we close the window using the close tab at the top of the screen. I know how to do it using a close button but I was wondering if there is way to achieve the...
5
by: kalyangvd | last post by:
Hi Guys, I am trying to get the Field Id from the Parent Window in the pop up window using window.opener ex: var var1 = window.opener.document.getElementById("text1").value; ...
6
by: tabakaka | last post by:
what is the condition if i want to pop a new window once i close the current one? is it..? if window.close { window.open("abc.aspx", "abc",...
2
by: neha shah | last post by:
i have an aspx page in which a link in the grid view opens a popup page . the data in the grid view would be dynamic and i need to send the id of the row of grid while calling the child window. i...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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
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...

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.