dom/tests/js/lists.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/tests/js/lists.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,68 @@
     1.4 +<html>
     1.5 +<body>
     1.6 +<p>This test does a few things:
     1.7 +<ul>
     1.8 +  <li>It has a couple of:
     1.9 +  <ul>
    1.10 +      <li>Images: <IMG SRC="http://zabadubop/layers/tests/mzcolor.gif" ID="foo"> and
    1.11 +          <IMG SRC="http://peoplestage.netscape.com/kipp/nerdly_int.gif" NAME="kipp">.
    1.12 +      <li>Links to <a href="http://home.netscape.com">Netscape</a> and
    1.13 +          <A HREF="http://peoplestage.netscape.com/kipp">Kippy's Home Page</A>.
    1.14 +      <li>and Anchors to <a NAME="anchor1">here</A> and 
    1.15 +          <A name="anchor2">here</a>.
    1.16 +  </ul>
    1.17 +  <li>It dumps (check the JS console) the images, links and anchors using
    1.18 +      the document.images, document.links and document.anchors arrays.
    1.19 +  <li>Then it removes one of the images.
    1.20 +  <li>Dumps the images array again. This is to prove that the images array
    1.21 +      is live.
    1.22 +  <li>Adds back the image.
    1.23 +  <li>And the dumps the images array again. The image arrays order should
    1.24 +      now be different.
    1.25 +  <li>It gets a list of LIs (using getElementsByTagName()) and prints
    1.26 +      out all their tagNames. There should be 10.
    1.27 +</ul>
    1.28 +<script>
    1.29 +var x;
    1.30 +dump("Images:\n");
    1.31 +for (x=0; x < document.images.length; x++) {
    1.32 +  dump("Image#" + x + ": " + document.images[x].getDOMAttribute("SRC") + "\n");
    1.33 +}
    1.34 +dump("\nLinks:\n");
    1.35 +for (x=0; x < document.links.length; x++) {
    1.36 +  dump("Link#" + x + ": " + document.links[x].getDOMAttribute("HREF") + "\n");
    1.37 +}
    1.38 +dump("\nAnchors:\n");
    1.39 +for (x=0; x < document.anchors.length; x++) {
    1.40 +  dump("Anchors#" + x + ": " + document.anchors[x].getDOMAttribute("NAME") + "\n");
    1.41 +}
    1.42 +
    1.43 +dump("\nRemoving image\n");
    1.44 +var img=document.images[1];
    1.45 +var parent=img.parentNode;
    1.46 +parent.removeChild(img);
    1.47 +dump("Images:\n");
    1.48 +for (x=0; x < document.images.length; x++) {
    1.49 +  dump("Image#" + x + ": " + document.images[x].getDOMAttribute("SRC") + "\n");
    1.50 +}
    1.51 +
    1.52 +dump("\nInserting image back into list\n");
    1.53 +var sib=parent.childNodes[0];
    1.54 +parent.insertBefore(img, sib);
    1.55 +dump("Images:\n");
    1.56 +for (x=0; x < document.images.length; x++) {
    1.57 +  dump("Image#" + x + ": " + document.images[x].getDOMAttribute("SRC") + "\n");
    1.58 +}
    1.59 +
    1.60 +var lis = document.getElementsByTagName("LI");
    1.61 +dump("Lists:\n");
    1.62 +for (x=0; x < lis.length; x++) {
    1.63 +  dump(lis[x].tagName + "\n");
    1.64 +}
    1.65 +
    1.66 +dump("Named elements:\n");
    1.67 +dump(document.kipp.tagName + " with NAME=" + document.kipp.getDOMAttribute("NAME") + "\n");
    1.68 +
    1.69 +</script>
    1.70 +</body>
    1.71 +</html>
    1.72 \ No newline at end of file

mercurial