I feel dirty posting this up here but I’ve been racking my brain on this one for some two days now and I’m stuck.
I’m writing a function to create a DIV object on the page. My idea is that’ll it work on all 4th+ generation browsers. FOR THE LIFE OF ME I CAN’T GET IT TO WORK!!!
fnc has two arguments, ‘newDIVName’, which is suppose to be the name of the new DIV and ‘childOfDIV’, which is suppose to allow me to make the new div a child of an existing div. here’s my code:
function createDIV(newDIVName, childOfDIV)
{
if (childOfDIV = ” || childOfDIV == null)
{
if (documents.layers && window.Layer && document.classes )
{
document.layers[newDIVName] = new Layer(10);
document.layers[newDIVName].visibility = ‘hidden’;
}
else if (document.body)
{ var tempString = ‘<div style=”position:absolute;left:0px;top:0px;width:10px;”>new</div>’; }
if (document.body.insertAdjacentHTML)
{ document.body.insertAdjacentHTML(‘beforeEnd’, tempString); }
else if( typeof(document.body.innerHTML) != ‘undefined’ )
{ document.body.innerHTML += tempString; }
}
else
{
if (document.layers && window.Layer && document.classes )
{ document.layers[newDIVName] = new Layer(10, newDIVName);
document.layers[newDIVName].visibility = ‘hidden’; }
else if (document.body)
{ var tempString = ‘<div style=”position:absolute;left:0px;top:0px;width:10px;”>new</div>’; }
if (newDIVName.insertAdjacentHTML)
{ (eval(newDIVName)).insertAdjacentHTML(‘beforeEnd’, tempString); }
else if( typeof(document.body.innerHTML) != ‘undefined’ )
{ newDIVName.innerHTML += tempString; }
}
}