javascript waiting for activex to load before execting

Discussion in 'Javascript' started by Grant H., Jun 7, 2004.

  1. Grant H.

    Grant H. Guest

    hi all,

    i have a strange problem here & i'm not sure how to go about fixing
    it. Basically, I have a page with an activex control that gets launch
    with JS when a user clicks a "connect" button. Now, all i want to do
    is disable the button & change the text while the activex is loading.
    now, the code below should work, but what i'm seeing is that the js
    doesn't even start executing until the activex is loaded. so, what i'm
    expecting is the js to run down the function sequentially so:

    -the first 2 lines disable & change the text of the button
    -the active loads (the button is still disabled)
    -activex done load & i re-enable the button.

    what actually happens is: when i hit the button, it sits there & loads
    the activex, then runs down the function so the disable & re-enable of
    the buttons go really fast. any help would be appriciated!

    thanks!

    -grant.

    <object id="MyAppLaunch" type="application/x-oleobject"
    classid="CLSID:8E0FDFBC-77D4-43a1-9AD4-41F0EA8AFF7C"
    codebase="myapp.cab#version=2,1,0,1">
    </object>
    <script language="javascript">
    <!--

    function DoIt()
    {
    document.form1.Connect.value = "Please Wait...";
    document.form1.Connect.disabled = true;

    try{
    MyAppLaunch.Launch(1,2,3,4,5);
    }catch(oException){window.location.href="myapp.exe";}
    }
    document.form1.Connect.value = "Connect";
    document.form1.Connect.disabled = false;
    }
    -->
    </script>
     
    Grant H., Jun 7, 2004
    #1
    1. Advertising

  2. Hi grant,

    > what actually happens is: when i hit the button, it sits there & loads
    > the activex, then runs down the function so the disable & re-enable of
    > the buttons go really fast. any help would be appriciated!


    The problem is the way the browser handels its GUI updates. While
    running your script, there is no point where control is handed back
    to the browser so it can repaint. Therefor the best thing is to make
    a small delay in your execution to give the browser some time to repaint
    before initializing your object.

    function DoIt()
    {
    document.form1.Connect.value = "Please Wait...";
    document.form1.Connect.disabled = true;
    window.setTimeout("finishIt();",100);
    }

    function FinishIt() {

    try{
    MyAppLaunch.Launch(1,2,3,4,5);
    }catch(oException){
    window.location.href="myapp.exe";}
    }
    document.form1.Connect.value = "Connect";
    document.form1.Connect.disabled = false;
    }

    -->
    </script>

    That should do it.

    Good luck,
    Vincent
     
    Vincent van Beveren, Jun 8, 2004
    #2
    1. Advertising

  3. Grant H.

    Grant H. Guest

    Hi Vincent,

    you're absolutely right! I put the setTimeout in there & it works like
    a charm. thanks!!

    -grant

    Vincent van Beveren <> wrote in message news:<40c56f44$0$566$4all.nl>...
    > Hi grant,
    >
    > > what actually happens is: when i hit the button, it sits there & loads
    > > the activex, then runs down the function so the disable & re-enable of
    > > the buttons go really fast. any help would be appriciated!

    >
    > The problem is the way the browser handels its GUI updates. While
    > running your script, there is no point where control is handed back
    > to the browser so it can repaint. Therefor the best thing is to make
    > a small delay in your execution to give the browser some time to repaint
    > before initializing your object.
    >
    > function DoIt()
    > {
    > document.form1.Connect.value = "Please Wait...";
    > document.form1.Connect.disabled = true;
    > window.setTimeout("finishIt();",100);
    > }
    >
    > function FinishIt() {
    >
    > try{
    > MyAppLaunch.Launch(1,2,3,4,5);
    > }catch(oException){
    > window.location.href="myapp.exe";}
    > }
    > document.form1.Connect.value = "Connect";
    > document.form1.Connect.disabled = false;
    > }
    >
    > -->
    > </script>
    >
    > That should do it.
    >
    > Good luck,
    > Vincent
     
    Grant H., Jun 9, 2004
    #3
    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. Mark Richards
    Replies:
    2
    Views:
    1,121
    Andrew Thompson
    Oct 8, 2004
  2. Replies:
    0
    Views:
    896
  3. Josh
    Replies:
    3
    Views:
    286
  4. vml
    Replies:
    0
    Views:
    1,057
  5. Replies:
    4
    Views:
    167
Loading...

Share This Page