469,603 Members | 2,114 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,603 developers. It's quick & easy.

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 1618
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
reply views Thread by devrayhaan | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.