Wait until window closed before continuing

  • Follow


I am opening a windows (well, technically a greybox() call GB_show()
which shows a nicer window than normal), and want to wait until that
window is closed before moving to the next command.  However, when I
open the window, JavaScript immediately issues the next command
statement.  How can I get JavaScript to wait until the window is
closed before continuing?  Here's visually what I'm trying to do:

statement1;
GB_show('mycaption, 'http://www.mypage.com');
statement3;

When the window opens, JavaScript immediately executes statement 3.
I'd like:

statement1;
GB_show('mycaption, 'http://www.mypage.com');
wait-until-window-closes;
statement3;

Thanks for your help.

0
Reply eddieandrews (10) 8/24/2007 1:31:27 PM

Eddie wrote:
> I am opening a windows (well, technically a greybox() call GB_show()

What is a greybox(), please?

> which shows a nicer window than normal),

Assuming it is still a Window object, do you realize this is probably based
on a browser bug?

> and want to wait until that window is closed before moving to the
> next command.  However, when I open the window, JavaScript immediately
> issues the next command statement.  How can I get JavaScript to wait
> until the window is closed before continuing?

You cannot (ref. FAQ 4.20), but see below.

> Here's visually what I'm trying to do:
> 
> statement1;
> GB_show('mycaption, 'http://www.mypage.com');

BG_show() is not a built-in method.  Unless you say what your library is,
better what it actually does, only people experienced with that library can
help you.  Given the number of libraries out there, and most of them being
bad, it is unlikely to find such a person here.

> statement3;
> 
> When the window opens, JavaScript immediately executes statement 3.
> I'd like:
> 
> statement1;
> GB_show('mycaption, 'http://www.mypage.com');
> wait-until-window-closes;
> statement3;

Modal windows would be a solution, but they are MSHTML-proprietary.

Assuming this is about a Window object, you could check if the window was
closed once in a while:

  /**
   * @see http://pointedears.de/scripts/types.js
   */
  function isMethodType(s)
  {
    return /\b(function|object)\b/i.test(s);
  }

  function checkClosed(ms)
  {
    if (!w || w.closed)
    {
      if (isMethodType(typeof window.clearTimeout) && window.clearTimeout)
      {
        window.clearTimeout(t);
      }

      statement3;
    }
    else
    {
      t = window.setTimeout("checkClosed(" + ms + ")", ms);
    }
  }

  statement1;

  // retrieve the Window object reference
  var w = ...

  if (isMethodType(typeof window.setTimeout) && window.setTimeout)
  {
    var t = window.setTimeout("checkClosed(250)", 250);
  }


HTH

PointedEars
-- 
Prototype.js was written by people who don't know javascript for people
who don't know javascript. People who don't know javascript are not
the best source of advice on designing systems that use javascript.
  -- Richard Cornford, cljs, <f806at$ail$1$8300dec7@news.demon.co.uk>
0
Reply Thomas 8/24/2007 2:02:41 PM


> What is a greybox(), please?

Sorry. GreyBox (http://orangoo.com/labs/GreyBox/) is a JS window
library that pretties up a window, usually for alerts and pop-ups.

> BG_show() is not a built-in method...

Actually, it's GB_show() and it's the call to the window.  I don't
want to get sidetracked on GreyBox, since it's identical to issuing a
call to open a window.  It behaves the same way either way, and since
it's a windows, it can be called using normal JavaScript.  It's the
waiting until the window closes that's the real issue.

I'll check out your code sample to see if that helps.  Thanks.

0
Reply Eddie 8/24/2007 4:46:30 PM

Eddie meinte:
>> What is a greybox(), please?
> 
> Sorry. GreyBox (http://orangoo.com/labs/GreyBox/) is a JS window
> library that pretties up a window, usually for alerts and pop-ups.

> Actually, it's GB_show() and it's the call to the window.  I don't
> want to get sidetracked on GreyBox, since it's identical to issuing a
> call to open a window.  It behaves the same way either way, and since
> it's a windows, it can be called using normal JavaScript.  It's the
> waiting until the window closes that's the real issue.

1. Well, it's *not* a window. It's an ordinary div.
2. Thomas' code won't work, since it relies on a *window*.
3. Solution: Change the GB code that returns immediately after opening 
the "window" (and attaching a "close"-handler to the close-"button"), 
that it doesn't return and instead waits explicitly for the closing click.
4. On the mentioned website they state that there is a greybox group on 
google groups. Why not ask there?

> I'll check out your code sample to see if that helps.  Thanks.

I doubt it will.

Gregor



-- 
http://www.gregorkofler.at ::: Landschafts- und Reisefotografie
http://www.licht-blick.at  ::: Forum f�r Multivisionsvortr�ge
http://www.image2d.com     ::: Bildagentur f�r den alpinen Raum
0
Reply Gregor 8/26/2007 9:03:08 PM

Gregor Kofler wrote:
> Eddie meinte:
>>> What is a greybox(), please?
>> Sorry. GreyBox (http://orangoo.com/labs/GreyBox/) is a JS window
>> library that pretties up a window, usually for alerts and pop-ups.
>> 
>> Actually, it's GB_show() and it's the call to the window.  I don't
>> want to get sidetracked on GreyBox, since it's identical to issuing a
>> call to open a window.  It behaves the same way either way, and since
>> it's a windows, it can be called using normal JavaScript.  It's the
>> waiting until the window closes that's the real issue.
> 
> 1. Well, it's *not* a window. It's an ordinary div.
> 2. Thomas' code won't work, since it relies on a *window*.

It can be modified so that it does not wait for a window to be closed, but
for the `div' element no longer to be displayed.

> 3. Solution: Change the GB code that returns immediately after opening 
> the "window" (and attaching a "close"-handler to the close-"button"), 
> that it doesn't return and instead waits explicitly for the closing click.

That is another possibility.  Or GreyBox has means of its own.

> 4. On the mentioned website they state that there is a greybox group on 
> google groups. Why not ask there?

In this case I'd rather he asks here instead of getting supposed bad advice
from the people with supposed smattering there.


PointedEars
-- 
    realism:    HTML 4.01 Strict
    evangelism: XHTML 1.0 Strict
    madness:    XHTML 1.1 as application/xhtml+xml
                                                    -- Bjoern Hoehrmann
0
Reply Thomas 8/26/2007 9:59:01 PM

4 Replies
379 Views

(page loaded in 0.007 seconds)

Similiar Articles:













7/26/2012 11:44:31 PM


Reply: