473,396 Members | 1,968 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Waiting for ActiveX object to have initialized

Hello,

I need to dynamically load an activex object because what
object to load is based on certain conditions. Also I need to
wait for the object to have initialized before moving on. What I did
was having the activex object set a variable and have the javascript
spin on that variable (a wait function)...

function load() {
var newsection = document.createElement('div');
var newcode = '<object codebase = ' + what_to_load() + '....><script
javascript....>' +
' wait_on_new_activex_object_prop()</script>';
newsection.innerHTML = newcode;
....
}

Note that I did not want to overwrite the entire page by using
document.write(), that is why I created a new element to
load the activex object...

However this code does not work, the wait javascript function
wasn't executed at all (I tried to put an "alert()" there, it didnt
get called either)... it looks like IE cannot execute dynamically
created javascript.

Is there another way to accomplish what I am trying to do? Any
idea would be really helpful.

Thanks.

May 1 '06 #1
4 5658
ma**********@lycos.com said the following on 5/1/2006 4:32 AM:
Hello,

I need to dynamically load an activex object because what
object to load is based on certain conditions. Also I need to
wait for the object to have initialized before moving on. What I did
was having the activex object set a variable and have the javascript
spin on that variable (a wait function)...

function load() {
var newsection = document.createElement('div');
var newcode = '<object codebase = ' + what_to_load() + '....><script
javascript....>' +
' wait_on_new_activex_object_prop()</script>';
newsection.innerHTML = newcode;
Why are you using createElement and then trying to innerHTML something
into it? And, you aren't appending your newsection unless you left that
code out.
....
}

Note that I did not want to overwrite the entire page by using
document.write(), that is why I created a new element to
load the activex object...
You can do a document.write there if it is done while the page is loading.
However this code does not work, the wait javascript function
wasn't executed at all (I tried to put an "alert()" there, it didnt
get called either)... it looks like IE cannot execute dynamically
created javascript.
Sure it can. Just not the way you are trying to dynamically create it.
Is there another way to accomplish what I am trying to do? Any
idea would be really helpful.


Use createElement to create a script element, create its .text property
and off you go.

var newScript = document.createElement('script');
newScript.text = 'alert("This is the alert")';
document.getElementById('someContainer').appendChi ld(newScript);

But, why not use createElement to create the OBJECT tag as well?

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
May 1 '06 #2
VK

ma**********@lycos.com wrote:
Hello,

I need to dynamically load an activex object because what
object to load is based on certain conditions. Also I need to
wait for the object to have initialized before moving on. What I did
was having the activex object set a variable and have the javascript
spin on that variable (a wait function)...

function load() {
var newsection = document.createElement('div');
var newcode = '<object codebase = ' + what_to_load() + '....><script
javascript....>' +
' wait_on_new_activex_object_prop()</script>';
newsection.innerHTML = newcode;
....
}


Nice try, but you are late for few years. This trick was explored in
deep in 90's (with devastating results for IE users). Now at least this
hole (use <object> as inline browser) is pretty much closed on IE6. I
guess you tried first WebBrowserControl? If not yet then to save your
time: that was locked even prior the above.

Are the servers you are trying to communicate between yours? What kind
of communication are you seeking? There are some options.

May 1 '06 #3
Randy,

Thanks alot for the info. Unfortunately what you have suggested don't
seem to suit my need. What I need is a way to block execution until an
activex object has finished init (my activex objcet changes the state
of
a member variable when it finishes init) because I don't want to start
loading
a java applet until the activex object has completed init (they talk to
each
other, and they can be different objects/applets under different
circumstances
or user input)

I've noticed everytime I do a xxx.appendChild (yes I left it out,
thought
it was obvious), IE spawns a thread to run that, so I could not have
done

activexobj = document.createElement('object');
.......
document.appendChild(activexobj);
scriptobj = docuemtn.create('script');
scriptobj.text = '....';
document.appendChild(scriptobj);

because then the script will run in parallel of the loading of the
activex...
not to mention not blocking the calling thread at all... (appending the
script elelment to the div element does help either)

As mentioned I could not have done document.write() because it
overwrites the page, and my stuff is done at the body after the
page is loaded.... document.write() does block during loading because
it is run in the same thread...

I am quite new to javascript, I wonder if there is any other way
to acommplish what I need - dynamically load an active object
(not neccessarily known during load time) and block the javascript
execution until the object has executed an init function???

Thanks alot for you help.
Randy Webb wrote:
ma**********@lycos.com said the following on 5/1/2006 4:32 AM:
Hello,

I need to dynamically load an activex object because what
object to load is based on certain conditions. Also I need to
wait for the object to have initialized before moving on. What I did
was having the activex object set a variable and have the javascript
spin on that variable (a wait function)...

function load() {
var newsection = document.createElement('div');
var newcode = '<object codebase = ' + what_to_load() + '....><script
javascript....>' +
' wait_on_new_activex_object_prop()</script>';
newsection.innerHTML = newcode;


Why are you using createElement and then trying to innerHTML something
into it? And, you aren't appending your newsection unless you left that
code out.
....
}

Note that I did not want to overwrite the entire page by using
document.write(), that is why I created a new element to
load the activex object...


You can do a document.write there if it is done while the page is loading.
However this code does not work, the wait javascript function
wasn't executed at all (I tried to put an "alert()" there, it didnt
get called either)... it looks like IE cannot execute dynamically
created javascript.


Sure it can. Just not the way you are trying to dynamically create it.
Is there another way to accomplish what I am trying to do? Any
idea would be really helpful.


Use createElement to create a script element, create its .text property
and off you go.

var newScript = document.createElement('script');
newScript.text = 'alert("This is the alert")';
document.getElementById('someContainer').appendChi ld(newScript);

But, why not use createElement to create the OBJECT tag as well?

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/


May 2 '06 #4
VK

ma**********@lycos.com wrote:
I am quite new to javascript, I wonder if there is any other way
to acommplish what I need - dynamically load an active object
(not neccessarily known during load time) and block the javascript
execution until the object has executed an init function???

In IE both <object> and <script> have onreadystatechange handler you
can attach a listener, just like for XMLHttpRequest. The only
difference is that the readyState is reported in the regular IE string
notation instead of numbers:

"uninitialized" Object is not initialized with data.
"loading" Object is loading its data.
"loaded" Object has finished loading its data.
"interactive" User can interact with the object even though it is not
fully loaded.
"complete" Object is completely initialized.

This way you can:

function notifyObserver() {
if (this.readyState = 'complete') {
// object is loaded successfully
}
}

var myObject = document.createElement('OBJECT');
// prepare object
myObject.onreadystatechange = notifyObserver;
document.body.appendChild(myObject);

May 2 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: AnalogKid | last post by:
Short question: What's the difference between SingleUse and MultiUse ? Long question: I've been writing some sample code to see how different Instancing values and threading models work. I...
106
by: A | last post by:
Hi, I have always been taught to use an inialization list for initialising data members of a class. I realize that initialsizing primitives and pointers use an inialization list is exactly the...
1
by: Marwan | last post by:
Hello I am using asynchronous delegates to make a call to a COM ActiveX object, but even though the call occurs on a separate thread, my UI is still blocking. If i put the thread to sleep in my...
2
by: Grant H. | last post by:
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....
2
by: jdanoz | last post by:
Hello, i have a vb.net project with a reference to an ActiveX object (ocx). If i try to use the ocx from vb6 project (adding the reference) it works ok (using CreateObject). In vb.net, the...
0
by: swong4 | last post by:
Hi all, I am trying to use an ActiveX control on the server-side of an ASP.NET 2.0 application written in C#. The ActiveX control is a 3rd-party interface to a data feed used by my application...
5
by: Hansen | last post by:
Hi! I have a problem with an object not yet being initialized when I try to access it. Hence I would like to wait for the object to be initialized. I have the following code: try {...
5
by: NPotnis | last post by:
Hi , I am trying to host .Net UserControls in a MFC Application. The MFC Application is an ActiveX DLL. I inserted required managed code inside the MFC application, making it a mixed mode DLL....
2
by: abhimanyu | last post by:
Hi, I am building a project using C# in VS2005. I need to use a COM ActiveX control in my project but I do not have a Form on which I want to place this control. I only want to create an object...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.