Solved

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

Posted on 2003-11-09
11
959 Views
Last Modified: 2010-05-18
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
0
Comment
Question by:PaulCutcliffe
[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
  • 3
  • 3
  • 3
  • +2
11 Comments
 
LVL 10

Expert Comment

by:Nushi
ID: 9709621
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
 
LVL 25

Expert Comment

by:devic
ID: 9709735
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
 
LVL 25

Expert Comment

by:devic
ID: 9709740
oops, i mean in in 3 step:

<script>
   var PleaseWaitWinClose=true;
</script>
0
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 
LVL 25

Expert Comment

by:devic
ID: 9709741
or better in 3 step:

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

<body onload="PleaseWaitWinClose=true">
0
 
LVL 2

Expert Comment

by:jwyrick
ID: 9711430
try this

function closePleaseWait() {
      parent.pleaseWait.close();
   }
0
 
LVL 10

Expert Comment

by:NetGroove
ID: 9711549
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
 

Author Comment

by:PaulCutcliffe
ID: 9711746
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
 
LVL 10

Accepted Solution

by:
NetGroove earned 300 total points
ID: 9711810
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
 

Author Comment

by:PaulCutcliffe
ID: 9714027
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
 

Author Comment

by:PaulCutcliffe
ID: 9730841
Sorry, thought I'd accepted your answer already. I'll do it now.

It worked a treat, by the way, thanks.
0
 
LVL 10

Expert Comment

by:NetGroove
ID: 9730869
You are welcome.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
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…

691 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