How do you wait until an ActiveX control is loaded and then execute code?

I have a custom ActiveX Control and I want to load it using the <object> tag for users that visit the site.  This pops up the IE warning etc. etc. What I would like to do is execute certain javascript code when the control has been fully downloaded and installed....such as a redirect.   I can't seem to figure out how to do this - if I try a onload for the browser it redirects immediately after the warning pops up.  Here is some basic code example...please help.
<html xmlns="http://www.w3.org/1999/xhtml"> <head>
<title>Test</title>
<script type="text/javascript" src="/sdccommon/inc/pluginlicense.js"></script>
</head>
<script type="text/javascript" language="Javascript">
function CheckCMControl()
{
    //window.location.href="/bellsouth/asp/home.asp<%=qStr%>";
    alert ("redirect");
}
</script>

<body onload="CheckCMControl();">
<script language="javascript">
RenderLicense();
</script>
<object id="TgConfCtl" classid="CLSID:01113300-3E00-11D2-8470-0060089874ED" codebase="../../SDCCommon/Download/tgctlcm.cab#version=6,8,627,0" width="0" height="0">
</body>
</html>
huntersinclairAsked:
Who is Participating?
 
Computer101Connect With a Mentor Commented:
PAQed with points refunded (500)

Computer101
EE Admin
0
 
jentulmanCommented:
When you say a custom control, do you mean that you have written it or have access to the people that have?

If so then have the control itself call send a javascript function call your function once it has finished loading.
0
 
jentulmanCommented:
once more in english this time...

When you say a custom control, do you mean that you have written it or have access to the people that have?

If so then have the control itself, once it has finished loading, call a javascript function (e.g. axLoaded() ) and include this function in the page.
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
huntersinclairAuthor Commented:
I didn't write it myself and the control is already packaged up - so adding to it might be a bit of a pain to get the author to update it....I was hoping there was a more simplified solution.  Perhaps some generic event that is fired off when the object finishes loading.
0
 
jentulmanCommented:
was just a thought, in that case if you use embed tags rather than object tags there is an onload attribute for embed

http://msdn2.microsoft.com/en-us/library/ms536942.aspx

0
 
huntersinclairAuthor Commented:
So insted of :
<object id="TgConfCtl" classid="CLSID:01113300-3E00-11D2-8470-0060089874ED" codebase="../../SDCCommon/Download/tgctlcm.cab#version=6,8,627,0" width="0" height="0">

I would do :

<embed onload="CheckCMControl()" id="TgConfCtl" classid="CLSID:01113300-3E00-11D2-8470-0060089874ED" codebase="../../SDCCommon/Download/tgctlcm.cab#version=6,8,627,0" width="0" height="0">

??
0
 
huntersinclairAuthor Commented:
I tried the embed and I am not sure I can download the cab file for an install with it.  The situation I am dealing with is where the user has an old version of the control on their pc and I want to upgrade it and then redirect the browser after the upgrade.  I was trying to do this with the <object> tag and entering the version of the latest control so if they already have that version then it doesnt need to download anything....but if they had an older one then it attempts to download and install the latest control....problem is I don't know when that happens - I want to know when the control finishs downloading and installing and then redirect.
0
 
jentulmanCommented:
I'm very sorry, i just did some checking and embed wont work for activeX controls, so that doesn't move it on at all.

You could try adding onload to the object tag, but I have no idea of the level of browser support for that.
0
 
huntersinclairAuthor Commented:
yea onload is not an event for the object tag unfortunately.
0
 
jentulmanCommented:
Then my only suggestion remains as ealier with editing the control itself.
0
 
LeeKowalkowskiCommented:
Isn't it onreadystatechange you need?  (The test obj.readyState == "complete")

Although once it's loaded, if you redirect, it'll be unloaded again - or is this just an installation page?

--
Lee
0
 
huntersinclairAuthor Commented:
No - the readystate is set to 4 or complete as soon as the page loads - even if the module is not downloaded and installed yet - wierd.  I figured a way to do this - although it is a total hack...I basically setup a function that try to instanciate the activex control and then I call the function every second or so with a setTimeout and check it...the function fails if it can't instantiate the control and check the version and basically loops with a delay until it does, and when it does work and the version is right it redirects.  I wish there was a more elegant way.
0
 
jentulmanCommented:
> I wish there was a more elegant way.

Isn't that just the way with most of javascript/DOM stuff :)

I'd never have thought of onReadyStateChange, cheers Lee for teaching me something new.
0
All Courses

From novice to tech pro — start learning today.