Using the following script I include text and insert css into my page head at run time. However, although the css in inserted it does not take affect. Why?
(function () {
var styleEl = document.createElement("link");
styleEl.type = "text/css";
styleEl.href = "/static/css/widgets.css";
//document.getElementsByTagName('head')[0].appendChild(styleEl);
document.head.appendChild(styleEl);
var foo = "Goodbye World!";
document.write("<p class='example-widget-container'>Inside our anomymous function foo means '" + foo + '".</p>');
})();
document.write! See the warning in the spec. Use DOM methods instead.