Solved

popup window during upload

Posted on 2004-08-02
5
691 Views
Last Modified: 2012-05-05
Hi
I'm looking for a javascript which opens a popup window (child) during upload.

Checked already some solutions - but I have som trouble closing the child window after upload is finished.

I guess the parent window which starts the upload must have something like <body onload='childwindow.close;'> to close the child window when upload is complete??
Its not working yet...

Here is the code used so far by the parent:

function DoUpload() {
  childwindow= window.open('uploadprogress.php');
}

....
<FORM enctype='multipart/form-data' action='$uploadname' method='POST' name='myform' >
....
<INPUT TYPE=submit VALUE='go' OnClick='DoUpload()'>

the above code opens a new window, but how does it close after upload process ?
Thanks for your help.
Mathias
0
Comment
Question by:mfuerlinger
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 2

Expert Comment

by:Michael_Cicogna
ID: 11699272
Hi

Your idea should work well if you use the onUnload Event instead of the onload.

Michael
0
 
LVL 7

Expert Comment

by:Xxavier
ID: 11699307
It is

onload='childwindow.close()'
0
 
LVL 63

Accepted Solution

by:
Zvonko earned 180 total points
ID: 11701306
My proposal is this:

function DoUpload() {
  childwindow= window.open('uploadprogress.php');
  window.onunload = function(){childwindow.close()};
}


0
 
LVL 1

Author Comment

by:mfuerlinger
ID: 11706254
Zvonkos suggestions works fine for me: A tiny, easy and sexy sniplet. Thanks.

Here is the complete code in one file to open and close a window during file upload (embedded in php):

<?php
echo "
<HTML>
<HEAD><TITLE>UPLOAD</TITLE>
<SCRIPT LANGUAGE='JavaScript'>
function DoUpload() {
  theFeats =   'height=120,width=500,location=no,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no';
  theUniqueID = (new Date()).getTime() % 1000000000;
  childwindow = window.open('uploadprogress.php', theFeats);
  window.onunload = function(){childwindow.close()};
}
//-->
</SCRIPT>
</HEAD><BODY>
<FORM enctype='multipart/form-data' action='uploadtest.php' method='POST' name='myform'>

new files:
<INPUT TYPE=file NAME='filename' SIZE=25>
<INPUT TYPE=submit VALUE='go' OnClick='DoUpload()'>

</FORM>
</BODY></HTML>
";
?>


enjoy.
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 11707599
Thanks for points.
But you should change your script.
Like this:

<?php
echo "
<HTML>
<HEAD><TITLE>UPLOAD</TITLE>
<SCRIPT LANGUAGE='JavaScript'>
function DoUpload() {
  theFeats =   'height=120,width=500';
  childwindow = window.open('uploadprogress.php', 'Progress', theFeats);
  window.onunload = function(){childwindow.close()};
}
//-->
</SCRIPT>
</HEAD><BODY>
<FORM enctype='multipart/form-data' action='uploadtest.php' method='POST' name='myform'>

new files:
<INPUT TYPE=file NAME='filename' SIZE=25>
<INPUT TYPE=submit VALUE='go' OnClick='DoUpload()'>

</FORM>
</BODY></HTML>
";
?>
0

Featured Post

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In this article, we'll look how to sort an Array in JavaScript, including the more advanced techniques of sorting a collection of records either ascending or descending on two or more fields. Basic Sorting of Arrays First, let's look at the …
In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question