By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,490 Members | 1,489 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,490 IT Pros & Developers. It's quick & easy.

javascript waiting for activex to load before execting

P: n/a
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>
Jul 23 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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

Jul 23 '05 #2

P: n/a
Hi Vincent,

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

-grant

Vincent van Beveren <vi*****@provident.remove.this.nl> wrote in message news:<40*********************@news.xs4all.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

Jul 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.