Trying to create a div right after the body, but this code doesn't seem to work. Anyone know why?

Code JavaScript:
window.onload=function(){
var bodyTag = document.getElementsByTagName("body")[0];
var obamaDiv = document.createElement('div');
obamaDiv.setAttribute('id','obama2008ribbon');
bodyTag.appendChild(obamaDiv);
}