[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 202
  • Last Modified:

Close popup window after server processing

Hi,

I have a webpage(.aspx) where users can upload images.
I am using javascript to pop up a clientside window(saying "Please wait") when the user clicks on "Upload".
This upload button also triggers a postback to the server so image type checking can be performed and the image uploaded.
My problem is once the server is done processing the image and returns the .aspx page to the user how can I close the "Please wait" window?

I have seen similar posts suggesting this method:

MyWin = window.open()

and then

MyWin.close()

The opening bit works but then if I put the close bit in the page load handler of the .aspx page it doesn't work.
Does the javascript variable persist through postbacks? I don't know javascript at all.

Cheers
0
nathc100
Asked:
nathc100
  • 2
1 Solution
 
bastibartelCommented:
Hi there,

Make sure that the variable is outside the function opening the window,
so that it is still know upon re-entry of the function.

<script>
var MyWin;

function OpenIt()
{
    MyWin = window.open()
}
</script>
0
 
nathc100Author Commented:
Thanks bastibartel,

But didn't seem to work.

I ended up using RegisterStartupScript('CloseUp') in my code behind to call the javascript procedure.
And then in CloseUp() I did something like window.Open('',popup) then popup.close
Syntax is not correct just remembering off the top of my head.
0
 
bastibartelCommented:
Hi nathc100

The following works for me (on IE)
( needs a html document "./popup.html" which opens in popup window. )


<html>
<script type="text/javascript">
var MyWin;
function PopOn()
{   MyWin = window.open("./popup.html", "WaitWindow", "width=200,height=100,left=100,top=200");}

function PopOff()
{  MyWin.close();}
</script>

<body>
<a href="main.html" onCLick="PopOn(); return false"> please pop up</a>
<br>
<a href="main.html" onCLick="PopOff(); return false"> please close</a>
</body>
</html>


Cheers,
Sebastian
0
 
NetminderCommented:
Closed, 250 points refunded.
Netminder
Site Admin
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now