Okay so basically you want to write HTML inside the contents of your div. Say you have a div with the following id: myContentDiv
/**
* NOTICE HOW IM USING \ before " TO ESCAPE THE CHARACTERS INSIDE THE HTML STRING
*/
var yourCustomHTMLString = "<h1>this is a tag</h1><div class=\"yourClass\">something</div>";
var contentDiv = document.getElementById('myContentDiv');
contentDiv.innerHTML = yourCustomHTMLString;
Also, in your mark-up you need to specify a trigger for your JS, for instance an onload trigger.
window.onload = function(){
document.write(example_content);
}
And now say you want a function that will load an HTML string into a div.
function loadContent(HTMLstring, targetDivID)
{
var myDiv = document.getElementById(targetDivID);
myDiv.innerHTML = HTMLstring;
}
If you are trying to include a JS script inside another JS script, you need Ajax. If you are using a JS library, all common ones have a script load method predefined.