closing a window

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
gurjit
Forum Contributor
Posts: 314
Joined: Thu May 15, 2003 11:53 am
Location: UK

closing a window

Post by gurjit »

hi all,

i open a window from my parent window like this

window.open('../stationary/x_students_mailshots_csv.php', 'csv_create', 'top=0,left=0,location=1,menubar=0,resizable=0,scrollbars=no,status=0,toolbar=0,width=5,height=5');


the x_students_mailshots_csv.php file has the ob_start(); function for creating an excel file and downloading it on your machine. so when this window opens a download dialogue box appears.

my problem is when the user downloads the created excel file the open window cannot be closed. why?

i used
csv_create.close()
in both parent and child window and it does not work.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

You need identify the new window with a variable.

Code: Select all

var newWindow = window.open('../stationary/x_students_mailshots_csv.php', 'csv_create', 'top=0,left=0,location=1,menubar=0,resizable=0,scrollbars=no,status=0,toolbar=0,width=5,height=5'); 



//then to close it

newWindow.close()
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

did you save the returned handle from the function?

if so, that's what you ask to close.


Moved to Client-side.
User avatar
gurjit
Forum Contributor
Posts: 314
Joined: Thu May 15, 2003 11:53 am
Location: UK

Post by gurjit »

does not work.....

got javascript alert 'newWindow undefined'.....

at the bottom of the parent window page i put

<script>
newWindow.close();
</script>
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

did you save the window handle returned as newWindow?

Maybe you should post a link to a live version of this..
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post by patrikG »

no offense, gurjit, but google for it. You'll find tons of examples. The window-object and its open and close-methods have been around probably before ECMA-script became Javascript. ;)
Post Reply