 |
| 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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

September 23rd, 2005, 09:43 AM
|
|
Registered User
|
|
Join Date: Apr 2005
Posts: 352
Thanks: 14
Thanked 0 Times in 0 Posts
|
|
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.
|
|

September 23rd, 2005, 11:26 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
|
|
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)
|
|

September 23rd, 2005, 02:12 PM
|
|
Authorized User
|
|
Join Date: Jul 2005
Posts: 59
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Just a friendly reminder....
It probably won't work in Mozilla Firefox.
|
|

September 23rd, 2005, 09:15 PM
|
|
Authorized User
|
|
Join Date: Jul 2005
Posts: 59
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
> 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.
|
|

September 26th, 2005, 05:05 AM
|
|
Registered User
|
|
Join Date: Apr 2005
Posts: 352
Thanks: 14
Thanked 0 Times in 0 Posts
|
|
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.
|
|

September 26th, 2005, 07:54 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
|
|
> 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
|
|

September 27th, 2005, 04:48 AM
|
|
Registered User
|
|
Join Date: Apr 2005
Posts: 352
Thanks: 14
Thanked 0 Times in 0 Posts
|
|
********** 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.
|
|

September 28th, 2005, 10:01 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
|
|
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)
|
|

September 29th, 2005, 04:12 AM
|
|
Registered User
|
|
Join Date: Apr 2005
Posts: 352
Thanks: 14
Thanked 0 Times in 0 Posts
|
|
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.
|
|
 |