Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript How-To
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old September 23rd, 2005, 09:43 AM
Registered User
Points: 1,897, Level: 17
Points: 1,897, Level: 17 Points: 1,897, Level: 17 Points: 1,897, Level: 17
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2005
Location: Mumbai, Maharastra, India.
Posts: 352
Thanks: 14
Thanked 0 Times in 0 Posts
Send a message via Yahoo to rupen
Default How to close browser window?

Hi,
I have an asp page, what i want is that after the script has been executed the window should be closed automatically, i.e. by javascript.
This is what i have done but not working.
---------
<%
dim d
d = 1
if d = 1 then
    '' do something
else
    '' do something
end if
    response.write "Script Executed Successfully!!"
%>
<script language="text/javascript">
    window.self.close()
// i tried using "self.close()", "window.close()" but not working
</script>
--------
Please advice
----------


Rupen Anjaria.:)
------------------
We CAN'T avoid problems, but can solve it.
Reply With Quote
  #2 (permalink)  
Old September 23rd, 2005, 11:26 AM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Probably your script block is ignored as language="text/javascript" should be type="text/javascript".

You can use window.close() or self.close(), the user will be asked to confirm.

--

Joe (Microsoft MVP - XML)
Reply With Quote
  #3 (permalink)  
Old September 23rd, 2005, 02:12 PM
Authorized User
 
Join Date: Jul 2005
Location: New York, New York, .
Posts: 59
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Just a friendly reminder....

It probably won't work in Mozilla Firefox.

Reply With Quote
  #4 (permalink)  
Old September 23rd, 2005, 03:19 PM
richard.york's Avatar
Wrox Author
Points: 5,506, Level: 31
Points: 5,506, Level: 31 Points: 5,506, Level: 31 Points: 5,506, Level: 31
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Camby, IN, USA.
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

> It probably won't work in Mozilla Firefox.

Why not? I use self.close();, window.close(); all the time in Firefox.

Regards,
Rich

--
[http://www.smilingsouls.net]
Mail_IMAP: A PHP/C-Client/PEAR solution for webmail
Author: Beginning CSS: Cascading Style Sheets For Web Design
Reply With Quote
  #5 (permalink)  
Old September 23rd, 2005, 09:15 PM
Authorized User
 
Join Date: Jul 2005
Location: New York, New York, .
Posts: 59
Thanks: 0
Thanked 0 Times in 0 Posts
Default

 > It probably won't work in Mozilla Firefox.

Why not? I use self.close();, window.close(); all the time in Firefox.

I'm not talking about pop-up window.

<html>
<body>
<input type="button" value="close" onclick="javascript:window.close();">
</body>
</html>

The above won't work unless you do some change in setting.

Reply With Quote
  #6 (permalink)  
Old September 26th, 2005, 05:05 AM
Registered User
Points: 1,897, Level: 17
Points: 1,897, Level: 17 Points: 1,897, Level: 17 Points: 1,897, Level: 17
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2005
Location: Mumbai, Maharastra, India.
Posts: 352
Thanks: 14
Thanked 0 Times in 0 Posts
Send a message via Yahoo to rupen
Default

What if i don't want conformation while closing window? It should close automatically.

Rupen Anjaria.:)
------------------
We CAN'T avoid problems, but can solve it.
Reply With Quote
  #7 (permalink)  
Old September 26th, 2005, 07:54 AM
richard.york's Avatar
Wrox Author
Points: 5,506, Level: 31
Points: 5,506, Level: 31 Points: 5,506, Level: 31 Points: 5,506, Level: 31
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Camby, IN, USA.
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

> What if i don't want conformation while closing window? It should close automatically.

It will only close without confirmation if it is a popup that you have spawned. Otherwise, would you like to surf the web and your browser suddenly close without warning?? That's why there is a confirmation before closing a window that is not a popup, and yes, there is no way around it.

Regards,
Rich

--
[http://www.smilingsouls.net]
Mail_IMAP: A PHP/C-Client/PEAR solution for webmail
Author: Beginning CSS: Cascading Style Sheets For Web Design
Reply With Quote
  #8 (permalink)  
Old September 27th, 2005, 04:48 AM
Registered User
Points: 1,897, Level: 17
Points: 1,897, Level: 17 Points: 1,897, Level: 17 Points: 1,897, Level: 17
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2005
Location: Mumbai, Maharastra, India.
Posts: 352
Thanks: 14
Thanked 0 Times in 0 Posts
Send a message via Yahoo to rupen
Default

********** Try this it is working great now!!!!! -************
********
<script text="text/javascript">
{
window.opener="something";
window.close();
}
*****

Rupen Anjaria.:)
------------------
We CAN'T avoid problems, but can solve it.
Reply With Quote
  #9 (permalink)  
Old September 28th, 2005, 10:01 AM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

That hack will not work on all browsers and is slated to be fixed in the next IE release so don't rely on it.

One reason web apps have taken off in the last few years is that the browser offers a consistent user interface. Accept the fact that somethings can't be done. Why should you be able to close my browser, it's not something most desk tops apps do either, how about if Microsoft Word suddenly closed down half way through editing a page?

--

Joe (Microsoft MVP - XML)
Reply With Quote
  #10 (permalink)  
Old September 29th, 2005, 04:12 AM
Registered User
Points: 1,897, Level: 17
Points: 1,897, Level: 17 Points: 1,897, Level: 17 Points: 1,897, Level: 17
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2005
Location: Mumbai, Maharastra, India.
Posts: 352
Thanks: 14
Thanked 0 Times in 0 Posts
Send a message via Yahoo to rupen
Default

Let me tell you why i need this stuff:

This is timesheet web application on asp.

I have written an autocheck asp file which will check for the employees who have not entered time in db,
after checking it will send email to them, since i have to run this on specific time i have schedule this file on server, after executing the window remains in task bar and my NetAdmintr is not agree with this and so i have to close window automatically, further it is fixed that this script will run in IE only.

I don't have any other simple solution.

Please advice.



Rupen Anjaria.:)
------------------
We CAN'T avoid problems, but can solve it.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Browser close when screen saver close Rehanrana Pro VB 6 1 April 7th, 2008 03:09 AM
Close Browser Window MoisesZaragoza Javascript How-To 2 February 6th, 2007 08:02 PM
how to detect in asp.net browser window close connect2sandep ASP.NET 1.0 and 1.1 Professional 1 October 31st, 2005 05:01 AM
Close Parent window on opening child window pkdev Javascript How-To 8 April 11th, 2004 12:06 PM
How do i close pop-up window?: window.close () Burton HTML Code Clinic 2 September 8th, 2003 05:40 AM



All times are GMT -4. The time now is 02:18 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.