471,852 Members | 1,207 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

innerHTML and <script>

max
Hi
I want to load an external file into my page via XMLhttpRequest and
innerHTML.
The external file contains javascript code which is not executed during
or after insertion. All the HTML markup is displayed just fine....
basicly even this code doesnt work:

<div id='tmp'>original Content</div>

<script>
document.getElementById("tmp").innerHTML="<b>new</b>
Content<script>alert('not shown! why?');<\/script>";
</script>

looking at the page, "new Content" is shown with "new" bold as
expected, but there wont be the javascript alert!

can anyone help me?

thanks a lot

Max Fechner

Jul 6 '06 #1
1 1688
max said the following on 7/6/2006 5:28 PM:
Hi
I want to load an external file into my page via XMLhttpRequest and
innerHTML.
The external file contains javascript code which is not executed during
or after insertion. All the HTML markup is displayed just fine....
basicly even this code doesnt work:

<div id='tmp'>original Content</div>

<script>
document.getElementById("tmp").innerHTML="<b>new</b>
Content<script>alert('not shown! why?');<\/script>";
</script>

looking at the page, "new Content" is shown with "new" bold as
expected, but there wont be the javascript alert!

can anyone help me?

thanks a lot
<URL:
http://groups.google.com/group/comp.lang.javascript/browse_thread/thread/54bf7e85b3cdbe87/07d863bf209d3680?q=ajax+issue&rnum=1#07d863bf209d3 680>

Is a thread from a few days ago with the same problem, the explanation
of why it doesn't "work", and the solution to it.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Temporarily at: http://members.aol.com/_ht_a/hikksnotathome/cljfaq/
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jul 6 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Madhav | last post: by
1 post views Thread by Grzegorz ¦lusarek | last post: by
21 posts views Thread by hemant.singh | last post: by
aboka
reply views Thread by aboka | last post: by

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.