Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics 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
 
Old January 6th, 2010, 11:07 AM
Registered User
 
Join Date: Oct 2009
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default open a new window, then close the old one

how can i accomplish this with asp
 
Old January 8th, 2010, 04:51 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Simple answer: you can't.

Complex answer: you can't or at least not elegantly ;] Seriously though, the most you will be able to do with ASP is something such as:

asp Code:
Response.Write "<script language='JavaScript'>window.open('foo.html', 'new window');</script>"

Now to close your main browser window is bit of an issue. Typically when you try to call the window.close() JavaScript on a the main window you will get a warning to that says something like "The page is trying to close the browser window" blah blah blah. Some people have been able to supress this by using the following JavaScript:

javascript Code:
window.opener='x';
window.close();

The reason this works is because when you call window.close() JavaScript checks to see if the value of window.opener is null or not. If it is it assumes something is amiss and displays the error message, otherwise it closes the window. This is a hack and I have had spotty luck with it but it might work for you.

hth.
-Doug
__________________
===============================================
Doug Parsons
Wrox online library: Wrox Books 24 x 7
Did someone here help you? Click on their post!
"Easy is the path to wisdom for those not blinded by themselves."
===============================================





Similar Threads
Thread Thread Starter Forum Replies Last Post
Window.close muthuprakash83 Javascript How-To 0 August 7th, 2006 12:35 PM
I can open a new window but can't close it camelius ASP.NET 2.0 Basics 0 March 16th, 2006 06:26 AM
window.close() failing to...well...close! mheathcote Javascript How-To 2 October 31st, 2005 03:02 PM
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





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.