zoukankan      html  css  js  c++  java
  • 简易相册

    <!DOCTYPE html>
    <html>

    <head>
    <meta charset="UTF-8">
    <title>web相册</title>
    </head>
    <style type="text/css">
    .img_border{
    border: 3px solid #cd853f;
    }
    </style>
    <script type="text/javascript">
    var currentImgIndex=-1;//相当于图片的序号
    function showImg(index){
    if(isNaN(index))return;
    if(index<0||index>2)return;

    currentImgIndex=index;
    var thumbList=document.getElementsByName("thumb");
    var imgCanvas=document.getElementById("showImg");

    switch(index){
    case 0:
    var _img=document.createElement("img");
    imgCanvas.innerHTML=
    "<img src='img/360.png' width='400' height='300'/>";
    thumbList[0].className="img_border";
    thumbList[1].className=thumbList[2].className="";
    break;

    case 1:
    imgCanvas.innerHTML=
    "<img src='img/baidu.png'width='400' height='300' />"
    thumbList[1].className="img_border";
    thumbList[0].className=thumbList[2].className="";
    break;

    case 2:
    imgCanvas.innerHTML=
    "<img src='img/sougou.png' width='400' height='300'/>";
    thumbList[2].className="img_border";
    thumbList[0].className=thumbList[1].className="";
    break;
    default:
    imgCanvas.innerHTML=
    "<img src='' width='400' height='300'/>"
    }

    }

    function nextImg()
    {
    currentImgIndex++;
    if(currentImgIndex>2) currentImgIndex=2;
    showImg(currentImgIndex);
    }
    function preImg(){
    currentImgIndex--;
    if(currentImgIndex<0) currentImgIndex=0;
    showImg(currentImgIndex);
    }
    </script>
    <body>
    <h2>缩略图</h2>
    <table>
    <tr>
    <td><input type="button" value="<"onclick="preImg()"></td>
    <td><img src="img/360.png" width="150" height="75" name="thumb"onclick="showImg(0)"></td>
    <td><img src="img/baidu.png"width="150"height="65" name="thumb"onclick="showImg(1)"></td>
    <td><img src="img/sougou.png"width="150"height="65"name="thumb"onclick="showImg(2)"> </td>
    <td><input type="button"value=">" onclick="nextImg()"></td>
    </tr>
    </table>
    <div id="showImg"class="show_img">
    <img src="" width="400"height="300" />
    </div>
    </body>

    </html>

  • 相关阅读:
    关于 OpenSmtp 邮件标题过长后出现乱码问题的解决
    用于解析 sohu 新闻页面的 XSLT 文件
    CEGUI 0.7x实现下划线描边图文混排等效果
    Hash算法说明
    D3DXMatrixShadow 函数
    DLL动态链接库和LIB静态链接库之程序员经验分析
    printf格式控制符的完整格式(转载)
    深入说明HDR技术
    Irrlicht不定期分析
    8.3实例程序:平面阴影
  • 原文地址:https://www.cnblogs.com/wxhhts/p/8178820.html
Copyright © 2011-2022 走看看