Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

popup window during upload

Posted on 2004-08-02
5
Medium Priority
?
701 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
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 720 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
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…

916 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