function setCSS(css) {
try {
// append stylesheet to alter
document.getElementsByTagName("head")[0].appendChild(css);
} catch (e) {
setTimeout(function(){setCSS(css)}, 100);
}
}
// create CSS element to set up the page
var css = document.createElement("link");
css.setAttribute("href",path/to/stylesheet);
css.setAttribute("rel","stylesheet");
css.setAttribute("type","text/css");
// attempt to add the css and then keep trying till we do
setCSS(css);
css = null;