tenfourfox/dom/tests/js/lists.html
Cameron Kaiser c9b2922b70 hello FPR
2017-04-19 00:56:45 -07:00

68 lines
2.2 KiB
HTML

<html>
<body>
<p>This test does a few things:
<ul>
<li>It has a couple of:
<ul>
<li>Images: <IMG SRC="http://zabadubop/layers/tests/mzcolor.gif" ID="foo"> and
<IMG SRC="http://peoplestage.netscape.com/kipp/nerdly_int.gif" NAME="kipp">.
<li>Links to <a href="http://home.netscape.com">Netscape</a> and
<A HREF="http://peoplestage.netscape.com/kipp">Kippy's Home Page</A>.
<li>and Anchors to <a NAME="anchor1">here</A> and
<A name="anchor2">here</a>.
</ul>
<li>It dumps (check the JS console) the images, links and anchors using
the document.images, document.links and document.anchors arrays.
<li>Then it removes one of the images.
<li>Dumps the images array again. This is to prove that the images array
is live.
<li>Adds back the image.
<li>And the dumps the images array again. The image arrays order should
now be different.
<li>It gets a list of LIs (using getElementsByTagName()) and prints
out all their tagNames. There should be 10.
</ul>
<script>
var x;
dump("Images:\n");
for (x=0; x < document.images.length; x++) {
dump("Image#" + x + ": " + document.images[x].getDOMAttribute("SRC") + "\n");
}
dump("\nLinks:\n");
for (x=0; x < document.links.length; x++) {
dump("Link#" + x + ": " + document.links[x].getDOMAttribute("HREF") + "\n");
}
dump("\nAnchors:\n");
for (x=0; x < document.anchors.length; x++) {
dump("Anchors#" + x + ": " + document.anchors[x].getDOMAttribute("NAME") + "\n");
}
dump("\nRemoving image\n");
var img=document.images[1];
var parent=img.parentNode;
parent.removeChild(img);
dump("Images:\n");
for (x=0; x < document.images.length; x++) {
dump("Image#" + x + ": " + document.images[x].getDOMAttribute("SRC") + "\n");
}
dump("\nInserting image back into list\n");
var sib=parent.childNodes[0];
parent.insertBefore(img, sib);
dump("Images:\n");
for (x=0; x < document.images.length; x++) {
dump("Image#" + x + ": " + document.images[x].getDOMAttribute("SRC") + "\n");
}
var lis = document.getElementsByTagName("LI");
dump("Lists:\n");
for (x=0; x < lis.length; x++) {
dump(lis[x].tagName + "\n");
}
dump("Named elements:\n");
dump(document.kipp.tagName + " with NAME=" + document.kipp.getDOMAttribute("NAME") + "\n");
</script>
</body>
</html>