I have to place a script in the head that creates a DIV element and inserts this DIV into the body tag.
var condiv = document.createElement("div");
(condiv.innerHTML = " "),
condiv.setAttribute("class", "ads"),
document.body.appendChild(condiv),
0 === condiv.offsetHeight ||
(function () {
}
The script works when I insert it into the body but not before. Is there a way to add the DIV into the body when the script is located into the head (before) with pure javascript and not Jquery? Its very important to have it in the head, because I have to place it before other scripts in the head and I dont want to have this scripts in the body. I know, I could use document.head.appendChild but HTML elements in the head are not validate. Thank you for your time.