I'm having problems getting this to work. I first tried setting my script tags as strings and then using jquery replaceWith() to add them to the document after page load:
var a = '<script type="text/javascript">some script here</script>';
$('#someelement').replaceWith(a);
But I got string literal errors on that var. I then tried encoding the string like:
var a = '&left;script type="text/javascript">some script here<\/script>';
but sending that to replaceWith() outputs just that string to the browser.
Can someone please let me know how you would go about dynamically adding a <script> tag into the browser after page load, ideally via jQuery?
<script>tag to the document? - Pointyeval()function. But use ofeval()almost always suggests that there's a better way of doing what you are trying to do. - Nickdocument.writeand you call it after page loading it will destroy the page. - bobince<iframe>elements? You can defer setting the<iframe>URL until you're ready. - Pointy