Hello fellow JavaScripters, here is some code that I am working on to load styles into a page depending on the protocol of the URL. It seems to load the .css files correctly in FF but in IE I get an "document.head is null or not an object" error. was wondering if I cold get any assistance.

Here is the code:

window.onload = function(){
var protocol = document.location.protocol;
var ref = document.createElement('link');
ref.setAttribute('rel','stylesheet');
ref.setAttribute('type','text/css');
if(protocol == 'http:'){
ref.setAttribute('href','IE.css');
}else if(protocol == 'https:'){
ref.setAttribute('href','IEhttps.css');
}
document.head.appendChild(ref);