Try the following :
on the place you want to add your div create an empty div like this:
Code:
<div id="zDiv"></div>
and make your function like this:
Code:
function addDiv()
{
var scripttags = document.getElementById("zDiv");
var horizRule = document.createElement('div');
var newT = document.createTextNode("dddwdwdwddwdss");
horizRule.appendChild(newT);
scripttags.parentNode.replaceChild(horizRule,scripttags);
}
The purpose of this method is not to inser Before but to replace an empty div with the div you have created in your function.
So for that create and empty div at the place you want, give it an id and replace it with anything you want.