0

Have any advice. Why I can not add the javascript into a DOM?

var strScript = "<script type='text/javascript'></script>";
$("#someElement").append(strScript);
4
  • It doesn't do much, but that works just fine in my browser (using body instead of #someElement). Commented Jun 14, 2012 at 16:35
  • Why are you trying to append a script tag into the DOM instead of simply calling a function when you want something to be executed? Commented Jun 14, 2012 at 16:36
  • 1
    possible duplicate of jQuery: Can't append <script> element Commented Jun 14, 2012 at 16:37
  • ok. Thank all. now I have found the answer... Cheer !!! Commented Jun 14, 2012 at 16:43

2 Answers 2

1

See this post. The top-rated comment does a stand-up job of going through what works and why.

Sign up to request clarification or add additional context in comments.

Comments

0

You can always do

document.write('\x3Cscript src="your-jsfile.js" type="text/javascript" >\x3C/script>');

1 Comment

use document.body.innerHMTL += str instead of document.write( str );document.close();

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.