This one is a bit tricky:
I have a web page that allows the user to upload a file to the web server. The files in question can get fairly large for web uploads.
I want to create a popup when the page is submitted that tells the user to please wait. (easy enough)
This popup needs to be closed once the upload is complete. Here's the tricky part. Because the popup was loaded on submit, the javascript loses the handle to the popup once the page reloads, preventing it from closing through the handle.
Any thoughts on how to get around this?
how to close popups with javascript
Moderator: General Moderators
When the download completes, you could redirect to a new page that would close the popup window. document.close() or something =/
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
My problem is that once the form has been submitted, the handle to the popup is lost.
This closes the popup, but the form is not submitted:
This submits the form, but can't close the popup:
I need the best of both worlds
This closes the popup, but the form is not submitted:
Code: Select all
<script type="text/javascript">
function opennotify()
{
nw=window.open('waiting.php','waiting','height=100,width=300');
}
function closenotify()
{
nw.close();
}
</script>
</head>
<body>
<input type="submit" name="submit_o" value="Open" onclick="javascript:null(opennotify())" />
<input type="submit" name="submit_c" value="Close" onclick="javascript:null(closenotify())" />
</body>Code: Select all
<script type="text/javascript">
function opennotify()
{
nw=window.open('waiting.php','waiting','height=100,width=300');
}
function closenotify()
{
nw.close();
}
</script>
</head>
<body>
<form enctype="multipart/form-data" method="post" action="index.php">
<input type="submit" name="submit_o" value="Open" onclick="javascript:null(opennotify())" />
<input type="submit" name="submit_c" value="Close" onclick="javascript:null(closenotify())" />
</form>
</body>What about opening a window with the same name on the 2nd page, then closing it?
Page1
Page2
If that doesn't work (though it should), try getting the popup window to close itself. Throw a function in that window that checks it's parent window every 250 ms or so for a particular element. If that element exists, close the window.
Page1
Code: Select all
window.open('myPage.php','specificName');Code: Select all
blankWindow = window.open('blank.php','specificName');
blankWindow.close();If that doesn't work (though it should), try getting the popup window to close itself. Throw a function in that window that checks it's parent window every 250 ms or so for a particular element. If that element exists, close the window.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.