By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,341 Members | 1,693 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,341 IT Pros & Developers. It's quick & easy.

innerHTML and <script>

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a
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.