Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > close current window using window.close()

Reply
Thread Tools

close current window using window.close()

 
 
Shang Wenbin
Guest
Posts: n/a
 
      09-01-2005
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.
 
Reply With Quote
 
 
 
 
andreister@gmail.com
Guest
Posts: n/a
 
      09-01-2005
Hope this helps:

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

..Andrew

 
Reply With Quote
 
 
 
 
ewosch
Guest
Posts: n/a
 
      09-01-2005
This alert occurs only if there is only one window and cannot be
switched off.

 
Reply With Quote
 
andreister@gmail.com
Guest
Posts: n/a
 
      09-01-2005
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.

 
Reply With Quote
 
ijsaunders@gmail.com
Guest
Posts: n/a
 
      09-01-2005
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

 
Reply With Quote
 
Shang Wenbin
Guest
Posts: n/a
 
      09-01-2005
http://www.velocityreviews.com/forums/(E-Mail Removed) 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
 
Reply With Quote
 
Gérard Talbot
Guest
Posts: n/a
 
      09-01-2005
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
 
Reply With Quote
 
Randy Webb
Guest
Posts: n/a
 
      09-01-2005
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
 
Reply With Quote
 
Grard Talbot
Guest
Posts: n/a
 
      09-01-2005
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.

Grard
--
remove blah to email me
 
Reply With Quote
 
Randy Webb
Guest
Posts: n/a
 
      09-01-2005
Grard 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to close a TCP socket? (TCPSocket#close doesn't close it) Iñaki Baz Castillo Ruby 7 01-12-2010 01:32 PM
close all child windows when close the main window jrefactors@hotmail.com HTML 6 08-07-2008 09:10 AM
perform an action when we close the window using the close tab at the top of the screen tapanreddy@gmail.com Javascript 4 04-10-2007 09:37 PM
close all child windows when close the main window jrefactors@hotmail.com Javascript 3 01-16-2005 10:06 PM
Self.close() window without the dialog close?Yes/NO Walter Beierdonck Javascript 1 04-30-2004 02:48 PM



Advertisments