"Jim Davis" <ne********@vbo ston.comwrote in message
news:dr******** *************** *******@giganew s.com...
"Randy Webb" <Hi************ @aol.comwrote in message
news:3P******** *************** *******@comcast .com...
>PJ said the following on 7/19/2006 10:43 AM:
>>Greetings.. .
*snip*
>>However the HTML have a SCRIPT tag that the browser should process, but
it doesn't.
Script blocks inserted via innerHTML don't get executed in any browser
other than NS6
One wrinkle to this.
IE will parse/execute a script block injected into a DIV - however you
must first set the innerHTML property to "null" THEN load the content as
in:
document.getEle mentById(Elemen tID).innerHTML = null;
document.getEle mentById(Elemen tID).innerHTML = NewContent;
Actually I've fibbed a little. More information:
To get the injected script to actually run in IE you also need to set the
"defer" attribute on the script element to "defer" as in:
<script type="text/javascript" defer="defer">
alert("My Script's a runnin'!");
</script>
So to just let injected script run (in IE) you need to just set the "defer"
attribute.
Setting the innerHTML to null is not actually required to run the script
however it's still a VERY good idea. The reason is because IE will not
automatically over-write any existing functions unless you do this. Setting
the innerHTML to null actually unloads all functions defined in the
DIV-contained script elements and allows new ones of the same name(s) to be
created.
For example if you had a function called "Init()" in multiple pieces of
content IE would always run the first instance loaded into the DIV UNLESS
you "null" the container before loading the subsequent block.
The "pages" in my applications (all content retrieved via an XMLHttpRequest
call and injected into a DIV ) all reference a created psuedo-scope called
"Page" and have certain standardized functions ("Page.Init( )" which
initilizes the page, "Page.Denit ()" which run when the page is unloaded and
"Page.Renit ()" which is run when the page is resurfaced but not reloaded).
The nulling of the container DIV is neccessary to allow the replacement
functions to be properly added to the model.
Jim Davis