Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

popup window during upload

Posted on 2004-08-02
5
Medium Priority
?
698 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 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's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
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…

721 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