javascript waiting for activex to load before execting

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Grant H.

    javascript waiting for activex to load before execting

    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="applicati on/x-oleobject"
    classid="CLSID: 8E0FDFBC-77D4-43a1-9AD4-41F0EA8AFF7C"
    codebase="myapp .cab#version=2, 1,0,1">
    </object>
    <script language="javas cript">
    <!--

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

    try{
    MyAppLaunch.Lau nch(1,2,3,4,5);
    }catch(oExcepti on){window.loca tion.href="myap p.exe";}
    }
    document.form1. Connect.value = "Connect";
    document.form1. Connect.disable d = false;
    }
    -->
    </script>
  • Vincent van Beveren

    #2
    Re: javascript waiting for activex to load before execting

    Hi grant,
    [color=blue]
    > 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![/color]

    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.disable d = true;
    window.setTimeo ut("finishIt(); ",100);
    }

    function FinishIt() {

    try{
    MyAppLaunch.Lau nch(1,2,3,4,5);
    }catch(oExcepti on){
    window.location .href="myapp.ex e";}
    }
    document.form1. Connect.value = "Connect";
    document.form1. Connect.disable d = false;
    }

    -->
    </script>

    That should do it.

    Good luck,
    Vincent

    Comment

    • Grant H.

      #3
      Re: javascript waiting for activex to load before execting

      Hi Vincent,

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

      -grant

      Vincent van Beveren <vincent@provid ent.remove.this .nl> wrote in message news:<40c56f44$ 0$566$e4fe514c@ news.xs4all.nl> ...[color=blue]
      > Hi grant,
      >[color=green]
      > > 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![/color]
      >
      > 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.disable d = true;
      > window.setTimeo ut("finishIt(); ",100);
      > }
      >
      > function FinishIt() {
      >
      > try{
      > MyAppLaunch.Lau nch(1,2,3,4,5);
      > }catch(oExcepti on){
      > window.location .href="myapp.ex e";}
      > }
      > document.form1. Connect.value = "Connect";
      > document.form1. Connect.disable d = false;
      > }
      >
      > -->
      > </script>
      >
      > That should do it.
      >
      > Good luck,
      > Vincent[/color]

      Comment

      Working...