使用包含散列标签的链接在加载时触发插件滑动框

Fire the plugin swipebox on load with links that include hash tag

html代码:

<a id="image1" href="images/1.jpg" class="swipebox" title="My Caption">
    <img src="images/1mini.jpg" alt="image" />
</a>

当用户输入以“#1”结尾的 link 时触发 pugin 的 Js 代码

<script type="text/javascript">
    $(document).ready(function(){
        if(window.location.hash == "#1") {
            $( '#image1' ).swipebox();
        }
    });
</script>

我想通了,js代码

$( '#image1' ).swipebox();

仅当我单击图像时才有效。但我需要在页面加载期间它已经弹出。

在页面加载时打开 swipebox;你能试试下面的代码吗:

<script type="text/javascript">
    $(document).ready(function(){
        if(window.location.hash == "#1") {
            $( '#image1' ).swipebox();
            $( '#image1' ).click();//click the image programmatically
        }
    });
</script>