innerHTML and <script>

M

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
 
R

Randy Webb

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...209d3680?q=ajax+issue&rnum=1#07d863bf209d3680>

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top