I have the following script:
<script type="text/javascript">
$(document).ready(function(){
document.write("<script type=\"text/javascript\" src=\"http://site.com/script.js\"><\/script>");
});
</script>
When I put this into the page, it redirects to the script, which I do not want.
I want to echo this javascript file where I insert the code above, so
it is loaded once the page has. Currently when I am using the script
above, it is only displaying the contents of the javascript file, and
not the whole page.
I want it to put it into the page where I place this script.
I’m doing this so that the script its calling is basically loaded in place once the page has, as currently this script is causing the page to hold up while it loads.
Thank you.
Try:
document.writewill add to the document when called before the document is loaded, but after that it’ll replace the existing content.