Popup Window Popup Timing

G

Guest

Hi,
I am using a popup window in my application and the problem I'm having is
that even though I tell it to display before a while loop, it only displays
after the while loop completes. Please take a look at the code below. Is
there a way to get it to pop up before the while loop starts?

p=window.createPopup();
var pbody=p.document.body;
pbody.style.backgroundColor="white";
pbody.style.border="solid black 2px";
pbody.innerHTML="All containers on same File/DO will be automatically
selected. Please wait for this window to close.";
p.show(150,150,200,90,document.body);
while (i<len)
{
...this while loop takes about 7 seconds to complete...
}

Thanks,
John
 
B

Bruce Barker

the browser is a standard windows app. a window will not appear until the
main thread (also the one client script is running in) calls the window loop
(doevents).

the workaround is simple, break you code into 2 parts and use
window.setTimeout (which uses a standard windows event) to run the second
part after a windows loop has been run.

p=window.createPopup();
var pbody=p.document.body;
pbody.style.backgroundColor="white";
pbody.style.border="solid black 2px";
pbody.innerHTML="All containers on same File/DO will be automatically
selected.
Please wait for this window to close.";
p.show(150,150,200,90,document.body);
window.setTimeout('doWork()',1);
}

function doWork()
{
while (i<len)
{
...this while loop takes about 7 seconds to complete...
}
}

-- bruce (sqlwork.com)
 
M

Marius Tennes Krogh

John Walker said:
Hi,
I am using a popup window in my application and the problem I'm having is
that even though I tell it to display before a while loop, it only
displays
after the while loop completes. Please take a look at the code below. Is
there a way to get it to pop up before the while loop starts?

p=window.createPopup();
var pbody=p.document.body;
pbody.style.backgroundColor="white";
pbody.style.border="solid black 2px";
pbody.innerHTML="All containers on same File/DO will be automatically
selected. Please wait for this window to close.";
p.show(150,150,200,90,document.body);
while (i<len)
{
...this while loop takes about 7 seconds to complete...
}

Thanks,
John

You can split the function into two functions and run them with a third
function. The key is to start the loop with a little delay.
-------------------------------------------------
function ShowMessage(){
p=window.createPopup();
var pbody=p.document.body;
pbody.style.backgroundColor="white";
pbody.style.border="solid black 2px";
pbody.innerHTML="All containers on same File/DO will be automatically
selected. Please wait for this window to close.";
p.show(150,150,200,90,document.body);
}

function StartLoop(){
while (i<len)
{
...this while loop takes about 7 seconds to complete...
}
}

function StartItAll(){
ShowMessage();
setTimeout("RunLoop()", 10);
}
 

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

Forum statistics

Threads
473,733
Messages
2,569,440
Members
44,830
Latest member
ZADIva7383

Latest Threads

Top