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/