Popup window: "Please wait while your file is submitted..." - how to close again from the "Thank you, your file has been submitted" window?

I am developing a website which enables users to submit files, some if which are quite big (realtive to the connection speed). Sadly, my JavaScript abilities are very limited, so I'm struggling with quite a simple bit.

So the user doesn't give up waiting for the file transfer, I have made it open a second browser window, with a message saying "Please wait while your file is submitted", with an hourglass animate GIF.

This all works nicely so far, from a line saying:

   windowPleaseWait = window.open('pleasewait.html', 'windowPleaseWait', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=600,height=200,left=200,top=200');

Now, all I want to do is close this Window, if it's open, from the new window that says "Thank you, your file has been submitted". I'm using a line like this:

   pleaseWait.close();

But, as this is a new page, it doesn't seem to know what 'pleaseWait' is.

I know this because, if I open the window & then close it from within the same window, it works, by calling these functions, for example:

   function openPleaseWait() {
      pleaseWait = window.open('http:pleasewait.html', 'PleaseWait', 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, width=600, height=200, left=200, top=200');
      pleaseWait.focus;
   }

   function closePleaseWait() {
      pleaseWait.close();
   }

So, my question is, how can I get a hold of this popup window from within the new page? This new page appears in the same browser window as the one that opened the popup window, if you follow - I know you can't close windows you didn't open.

Any help appreciated,

Paul
PaulCutcliffeAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

NushiCommented:
hi there.

you can do a small trick which will work.
instead of submitting the original page (top)
use frame/Iframe and sent all teh data from there.

(do the submit form the inner frame)
in this way you wont lose the pleaseWait womdow and you will be able to close him,
simply by using JS from the retuned page.

FRAME -> SUBMIT -> call JS function in the top frame which close the pleaseWait.

Nushi.


0
devicCommented:
hi PaulCutcliffe,

1. add in your main page:
==================================
<script>
    var PleaseWaitWinClose=false;
</script>

2. in popup add this:
==================================
<script>
function checkOpener()
{
      if(!opener.PleaseWaitWinClose)
      {
            setTimeout("checkOpener()",100)
      }
      else
      {
            self.close();
      }
}
checkOpener();
</script>

3.in new page insert this:
===============================
<script>
    var PleaseWaitWinClose=false;
</script>
0
devicCommented:
oops, i mean in in 3 step:

<script>
   var PleaseWaitWinClose=true;
</script>
0
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

devicCommented:
or better in 3 step:

<script>
   var PleaseWaitWinClose=false;
</script>

<body onload="PleaseWaitWinClose=true">
0
jwyrickCommented:
try this

function closePleaseWait() {
      parent.pleaseWait.close();
   }
0
NetGrooveCommented:
Here is my trick:

Your origianal window opens the popup like you stated:

 function openPleaseWait() {
     pleaseWait = window.open('http:pleasewait.html', 'PleaseWait', 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, width=600, height=200, left=200, top=200');
     pleaseWait.focus;
  }



Now your Thank You page can do a simmelar call and close the popup.
Like this:

  function closePleaseWait() {
     pleaseWait = window.open('', 'PleaseWait');
     pleaseWait.close();
  }


The trick is that the popup gets the window name from the secons parameter in window.open()
Reopening a new window with same window name fetches the same previously opened popup window and you can close it.

Good luck,
NetGroove

0
PaulCutcliffeAuthor Commented:
Thank you NetGroove, perfect. I actually did this in the onUnLoad event of the page that opened it, but the principle was the same.

One thing though, the page sometimes closes without having opened the popup, for example if the user  cancels instead of submitting a file. Is there an way of checking? Otherwise, when the other window isn't opened, it flashes up another window. I thought of specifying the dimensions & things like that, but that would affect the real popup window too. Can I test for its presence before opening it?

Thanks
0
NetGrooveCommented:
Sorry, there is no window detection without holding an object link or reference to that popup window.

Only trick I can recommend is to open the closing window on the far right bottom side, let say 20000 pixel.
Like this:

  function closePleaseWait() {
     pleaseWait = window.open('', 'PleaseWait', 'left=20000, top=20000');
     pleaseWait.close();
  }


0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
PaulCutcliffeAuthor Commented:
Yeah, I was going to try that, but was worried about whether the existing window would move to those coordinates before closing, but I'll try it now.

Thanks.
0
PaulCutcliffeAuthor Commented:
Sorry, thought I'd accepted your answer already. I'll do it now.

It worked a treat, by the way, thanks.
0
NetGrooveCommented:
You are welcome.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.