TOP - JavaScript - Document - images[]配列

HTMLドキュメント内のIMG要素のImageオブジェクトが格納される配列です。


オブジェクト1.images[]

オブジェクト1 : Documentオブジェクト(通常は、window.document等)


(例)

<SCRIPT type="text/javascript">
    var w1;

    function btnclick()
    {
        w1 = window.open("", "", "height=600,width=250");
        w1.moveTo(100,100);
        var s_html = "";
        s_html += "<html>\n";
        s_html += "<head>\n";
        s_html += '<script type="text/javascript">' + "\n";
        s_html += "<!--\n";
        s_html += 'function view_form()' + "\n";
        s_html += '{' + "\n";
        s_html += '    var i;' + "\n";
        s_html += '    var s_image;' + "\n";
        s_html += '    s_image = window.document.images[0].src.toString();' + "\n";
        s_html += '    for (i=0; i<4; i++)' + "\n";
        s_html += '    {' + "\n";
        s_html += '       window.document.images[i].src '
               +              '= window.document.images[i+1].src.toString();' + "\n";
        s_html += '    }' + "\n";
        s_html += '    window.document.images[4].src = s_image;' + "\n";
        s_html += '}' + "\n";
        s_html += "\/\/-->\n";
        s_html += "<\/script>\n";
        s_html += "</head>\n";
        s_html += "<body>\n";
        s_html += '<form name="form1">' + "\n";
        s_html += '<input type="button" name="view_button" '
               +      'value="連続して押すと画像がスクロールします" ';
        s_html += 'onclick="view_form()"><br>' + "\n";
        s_html += '<img name="image_view_01" src="img/mov_img_01.png"><br>' + "\n";
        s_html += '<img name="image_view_02" src="img/mov_img_02.png"><br>' + "\n";
        s_html += '<img name="image_view_03" src="img/mov_img_03.png"><br>' + "\n";
        s_html += '<img name="image_view_04" src="img/mov_img_04.png"><br>' + "\n";
        s_html += '<img name="image_view_05" src="img/mov_img_05.png"><br>' + "\n";
        s_html += '</form>' + "\n";
        s_html += "</body>\n";
        s_html += "</html>\n";
        w1.document.write(s_html);
        w1.document.close();
    }
<!--
//-->
</SCRIPT>


Copyright(C) 2006-2011 CLAYPOT. All Rights Reserved.