2
2obvious
This is a pipe dream, I realize, but I'm trying to emulate the
functionality of the W3C DOM-supported document.getElementsByTagName
method under the very nightmarish Netscape 4.
Through some sleuthing, I was able to find what serves as a
document.getElementById emulator at
http://www.xs4all.nl/~ppk/js/dhtmloptions.html#versionb.
(Below is the code; this clever algorithm is painstakingly explained
at the site above.)
Anyhoo: I figured that by zeroing in on the tag property (if such a
property exists) instead of the ID property, I would be well on my way
to emulating getElementsByTagName. But I've had no success, and I
can't find a comprehensive enough explanation of Netscape 4's layered
DOM to figure out how to zoom in on properties like className or tag.
If anyone knows how to get a tag under NN4, or knows of a thorough NN4
DOM explication online, or knows how to hack this code to make it
emulate get...tag, I would greatly appreciate your insight.
function getObj(name)
{
if (document.getElementById)
{
this.obj = document.getElementById(name);
this.style = document.getElementById(name).style;
}
else if (document.all)
{
this.obj = document.all[name];
this.style = document.all[name].style;
}
else if (document.layers)
{
this.obj = getObjNN4(document,name);
this.style = this.obj;
}
}
function getObjNN4(obj,name)
{
var x = obj.layers;
var foundLayer;
for (var i=0;i<x.length;i++)
{
if (x.id == name)
foundLayer = x;
else if (x.layers.length)
var tmp = getObjNN4(x,name);
if (tmp) foundLayer = tmp;
}
return foundLayer;
}
functionality of the W3C DOM-supported document.getElementsByTagName
method under the very nightmarish Netscape 4.
Through some sleuthing, I was able to find what serves as a
document.getElementById emulator at
http://www.xs4all.nl/~ppk/js/dhtmloptions.html#versionb.
(Below is the code; this clever algorithm is painstakingly explained
at the site above.)
Anyhoo: I figured that by zeroing in on the tag property (if such a
property exists) instead of the ID property, I would be well on my way
to emulating getElementsByTagName. But I've had no success, and I
can't find a comprehensive enough explanation of Netscape 4's layered
DOM to figure out how to zoom in on properties like className or tag.
If anyone knows how to get a tag under NN4, or knows of a thorough NN4
DOM explication online, or knows how to hack this code to make it
emulate get...tag, I would greatly appreciate your insight.
function getObj(name)
{
if (document.getElementById)
{
this.obj = document.getElementById(name);
this.style = document.getElementById(name).style;
}
else if (document.all)
{
this.obj = document.all[name];
this.style = document.all[name].style;
}
else if (document.layers)
{
this.obj = getObjNN4(document,name);
this.style = this.obj;
}
}
function getObjNN4(obj,name)
{
var x = obj.layers;
var foundLayer;
for (var i=0;i<x.length;i++)
{
if (x.id == name)
foundLayer = x;
else if (x.layers.length)
var tmp = getObjNN4(x,name);
if (tmp) foundLayer = tmp;
}
return foundLayer;
}