How to insert a block of javascript code to a html page…

Issue: innerHTML simply writes HTML as a string; it doesn’t call the javascript interpreter to parse and execute any scripts that are part of the string

Reference: http://www.webmasterworld.com/forum91/2912.htm

Solution: manually find these scripts inside the text string and append them to the document

Comments (1)

  1. 4:35 pm, October 31, 2008Anonymous  / Reply

    Thanks, this was very helpful. I was using a javascript templating language called ejs : http://embeddedjs.com/. Turns out that after the template is processed it is assigned to an element through innerHTML. I used your code here to help replace any js code in the template that would not normally run and append correctly.

    Ben

Leave a Reply

Allowed Tags - You may use these HTML tags and attributes in your comment.

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Pingbacks (0)

› No pingbacks yet.