Popup Window Popup Timing

Discussion in 'ASP .Net' started by =?Utf-8?B?Sm9obiBXYWxrZXI=?=, Nov 4, 2005.

  1. 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
     
    =?Utf-8?B?Sm9obiBXYWxrZXI=?=, Nov 4, 2005
    #1
    1. Advertising

  2. =?Utf-8?B?Sm9obiBXYWxrZXI=?=

    Bruce Barker Guest

    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)


    "John Walker" <> wrote in message
    news:...
    > 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
    >
     
    Bruce Barker, Nov 4, 2005
    #2
    1. Advertising

  3. "John Walker" <> wrote in message
    news:...
    > 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);
    }

    --------------------------
    Marius
     
    Marius Tennes Krogh, Nov 4, 2005
    #3
  4. Bruce,
    Been having a bad day, but this worked and feel a little better. Thanks.

    "Bruce Barker" wrote:

    > 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)
    >
    >
    > "John Walker" <> wrote in message
    > news:...
    > > 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
    > >

    >
    >
    >
     
    =?Utf-8?B?Sm9obiBXYWxrZXI=?=, Nov 4, 2005
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jay
    Replies:
    8
    Views:
    6,619
    livshitz
    Jun 12, 2011
  2. Jens Peter Hansen
    Replies:
    7
    Views:
    560
    Randy Webb
    Jun 19, 2004
  3. Raffi
    Replies:
    4
    Views:
    240
    Dr John Stockton
    Aug 12, 2004
  4. Russell
    Replies:
    2
    Views:
    302
    Russell
    Sep 13, 2004
  5. Rainmanjam

    Safari and Window.onload timing

    Rainmanjam, Dec 24, 2007, in forum: Javascript
    Replies:
    26
    Views:
    834
Loading...

Share This Page