473,763 Members | 5,610 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 38014
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=s elf; 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********@gmai l.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.javas cript 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.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Sep 1 '05 #10

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

Similar topics

3
5863
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 parameter. If I omit the target window's name, everything works fine except that my document is opened in a new window. window.open("somescript.php", "existing_target_window");
1
3372
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 normal window. Actually, I tried to close the parent window from the child modal window using parent.close syntax in onload event in child modal window. It actually closes the parent modal window, but the child modal window is not opened, why it is...
2
5096
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=\"" + bmpFilePath + "\""); Response.WriteFile(bmpFilePath); Response.Flush();
3
4547
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 will be its code in javascript?
7
3356
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 above. Waiting for some suggestions Thanks
5
2595
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; alert(var1); I also used as window.opener.document.loginForm.text1.value but the field value is not getting in the pop up window. What am i missing here. Please let me know what i am missing here.
6
1542
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", 'toolbar=0,scrollbars=1,location=0,statusbar=yes,menubar=no,resizable=no,width=800,height=220,left=100,top = 145'); } i've tried it. but it didnt work.
2
3524
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 get the id using sender.id, but how would i send this using window .open()?
0
9563
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9997
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9822
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8821
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7366
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5270
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5405
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3917
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2793
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.