【问题标题】:Simplest Ajax Photo Gallery最简单的 Ajax 照片库
【发布时间】:2011-04-11 22:07:28
【问题描述】:

我不认为“最简单”是主观的。

寻找一个可托管的照片库,它只显示一张图片并提供“下一张图片”和“上一张图片”,但无需重新加载页面。显然预缓存也很好。 PHP、Python、Ruby 或 JS。

【问题讨论】:

    标签: gallery image-gallery photo-gallery


    【解决方案1】:

    如果你想要简单,也许是这样的?

    <html>
        <body>
            <div>
                <img id="image">
            </img>
            </div>
            <table>
                <tr>
                    <td onclick="getImage("previous");">Previous</td>
                    <td onclick="getImage("next");">Next</td>
                </tr>
            </table>
            <script type="text/javascript">
              counter = 0;
              nextImage = new Image();
              previousImage = new Image();
              getImage = function(what) {
                if (what === "previous") {counter--;}
                else {counter++;}
                nextImage.src = "http://www.example.com/image?data=" + (counter + 1);
                previousImage.src = "http://www.example.com/image?data=" + (counter - 1);
    
                document.getElementById("image").src = "http://www.example.com/image?data=" + counter;
              }        
            </script>
        </body>
    </html>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-12-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-03-19
      相关资源
      最近更新 更多