473,889 Members | 1,568 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.create Element('div');
var newcode = '<object codebase = ' + what_to_load() + '....><script
javascript....> ' +
' wait_on_new_act ivex_object_pro p()</script>';
newsection.inne rHTML = 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 5702
ma**********@ly cos.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.create Element('div');
var newcode = '<object codebase = ' + what_to_load() + '....><script
javascript....> ' +
' wait_on_new_act ivex_object_pro p()</script>';
newsection.inne rHTML = 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.create Element('script ');
newScript.text = 'alert("This is the alert")';
document.getEle mentById('someC ontainer').appe ndChild(newScri pt);

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

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

ma**********@ly cos.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.create Element('div');
var newcode = '<object codebase = ' + what_to_load() + '....><script
javascript....> ' +
' wait_on_new_act ivex_object_pro p()</script>';
newsection.inne rHTML = 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 WebBrowserContr ol? 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.create Element('object ');
.......
document.append Child(activexob j);
scriptobj = docuemtn.create ('script');
scriptobj.text = '....';
document.append Child(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**********@ly cos.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.create Element('div');
var newcode = '<object codebase = ' + what_to_load() + '....><script
javascript....> ' +
' wait_on_new_act ivex_object_pro p()</script>';
newsection.inne rHTML = 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.create Element('script ');
newScript.text = 'alert("This is the alert")';
document.getEle mentById('someC ontainer').appe ndChild(newScri pt);

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

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


May 2 '06 #4
VK

ma**********@ly cos.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 onreadystatecha nge 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:

"uninitiali zed" Object is not initialized with data.
"loading" Object is loading its data.
"loaded" Object has finished loading its data.
"interactiv e" 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.readyStat e = 'complete') {
// object is loaded successfully
}
}

var myObject = document.create Element('OBJECT ');
// prepare object
myObject.onread ystatechange = notifyObserver;
document.body.a ppendChild(myOb ject);

May 2 '06 #5

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

Similar topics

8
4572
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 tried all main combinations of Instancing (Multiuse/Singleuse) and of Threading models (per object/pool). Here's what I found: MultiUse - Thread per Object
106
5642
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 same as an assignment, but for class types it has a different effect - it calls the copy constructor. My question is when to not use an initalisation list for initialising data members of a class?
1
3416
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 delegate call, the application is well behaved (no UI freeze), but the call to the com object causes the UI to lock up Do I have to manage calls to an ActiveX object differently than using the BeginInvoke and a callback A sample of the code I...
2
6094
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. 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...
2
8453
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 CreateObject works ok, the object gets initialized...
0
1283
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 and does not have a GUI. To accomplish this, I am trying to create a Windows.Form to host the ActiveX control with the intent that the events generated by the control could be used by the server for data processing.
5
4441
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 { if(gridArray == null) {
5
3201
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. I am following the KB article for mixed mode DLL's http://support.microsoft.com/?id=814472 I linked the DLL with /noentry option. Also I added and exported the DllEnsureInit and DllForceTerm methods in my DLL which call __crt_dll_initialize()...
2
2979
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 of this control class and use it right away, When I create an object and use the control, some of the methods dont work because the ActiveX control is not initialized properly. Does anyone have an idea on how to initialize an ActiveX control...
0
11198
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10791
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10889
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9609
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7993
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5829
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6029
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4647
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3256
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.