Hi all.
I have a bunch of pages that reference an external script from the
head section. I'd like to add additional <script> elements to the
pages' bodies, but I can't edit the pages themselves. I'd like to add
them from the existing script, but I need to make sure that the
elements get added to the end of the document's body section.
Using document.write("<script ..."); the elements get added to the
head section! I'm trying to use the following code, but it complains
that the body element is null when it executes. Any idea how I can
add external script references to a document from an existing external
script?
Thanks,
Brian
I've added this to the existing external script.
================================================
var hbxScriptElement = document.createElement("script");
hbxScriptElement.language = "JavaScript";
hbxScriptElement.type = "text/javascript";
hbxScriptElement.src = "shared/js/hbx.js";
document.onload = addElementToBody(hbxScriptElement);
function addElementToBody(el) {
eval("document.getElementsByTagName('body')[0].appendChild(el)");
}
================================================