zoukankan      html  css  js  c++  java
  • Javascript 第六章

    <html>
     <head>
         <meta charset=utf-8>   
         <title></title>
     </head>
     <body>
     <h1>Snapshots</h1>
     <ul>
         <li><a href="images/1 (1).png" title="picture1" alt="picture1">picture1</a></li>
         <li><a href="images/1 (2).png" title="picture2" alt="picture2">picture2</a></li>
         <li><a href="images/1 (3).png" title="picture3" alt="picture3">picture3</a></li>
     </ul>
     
     <img src="images/placeholder.png" alt="my image gallery" id="placeholder">
     <p id="description">Choose an image</p>
     
     
     <script>
    
     function addLoadEvent(func){
            var oldonload = window.onload;
            if (typeof oldonload != 'function') {
                window.onload = func;
            }else{
                window.onload = function(){
                    oldonload();
                    func();
                }
            }
        }
    
    
     function prepareGallery(){    
         if (!document.getElementsByTagName || !document.getElementById) return false;    
         links = document.getElementsByTagName("a");
         for (var i = 0,j = links.length;i<j; i++) {
             links[i].onclick = function(){
    return !showPic(this); } } } function showPic(whichPic){ if (!document.getElementById("placeholder")) return false; var source = whichPic.getAttribute("href"); var placeholder = document.getElementById("placeholder"); if (placeholder.nodeName != "IMG") return false; placeholder.setAttribute("src",source); if (document.getElementById("description")) { var text = whichPic.getAttribute("title"); var description = document.getElementById("description"); if (description.firstChild.nodeType == 3) { description.firstChild.nodeValue = text; } } return true; } addLoadEvent(prepareGallery); </script> </body> </html>
  • 相关阅读:
    [小技巧]记录PHP错误日志
    PHP __autoload函数(自动载入类文件)的使用方法
    php5.3以前的版本安装出现Fatal error: Call to undefined function mysql_connect()
    mysqlnoinstall5.1.62win32 安装
    [php]PHP错误处理
    哈希表1
    哈希表2
    WinSock編程的多線程式控制
    编码转换 unicode gbk big5
    Parameters转换为Variant数组
  • 原文地址:https://www.cnblogs.com/mguo/p/2954131.html
Copyright © 2011-2022 走看看