Wait until window closed before continuing

E

Eddie

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.
 
T

Thomas 'PointedEars' Lahn

Eddie said:
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
 
E

Eddie

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.
 
G

Gregor Kofler

Eddie meinte:
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
 
T

Thomas 'PointedEars' Lahn

Gregor said:
Eddie meinte:

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top