尝试通过url加载到jquery滑块中的特定幻灯片

时间:2013-04-03 07:57:31

标签: jquery arrays load slider

我正在尝试从位于单独页面上的按钮链接到滑块中的特定幻灯片,因此锚链接不起作用。我想在滑块文档中使用锚点链接,位于滑块上方,但是没有用。

理想情况下,我希望能够以这样的方式访问特定幻灯片。

http://myslider.com/index.html#1
http://myslider.com/index.html#2
http://myslider.com/index.html#3, etc.

我正在使用Awkward Showcase滑块。每张幻灯片位于div中,如下所示:

<div class="showcase-slide">
    <!-- Put the slide content in a div with the class .showcase-content. -->
    <div class="showcase-content">
        <img src="images/01.jpg" alt="01" />
    </div>
</div>

以下是滑块的示例页面:http://showcase.awkwardgroup.com/

基本上,我正在寻找一种通过指定网址直接加载到幻灯片2或4等的方法。

我知道我需要链接到数组,我想我需要在这个函数中添加一些内容......可能。

    var contentArray = [];
    var thumbnailArray = [];
    var content_count = 0;
    showcase.children('.showcase-slide').each(function()
    {
        // Get content
        var object = jQuery(this);
        content_count++;


        if(window.location.hash) {
        // Fragment exists
        var myhash = window.location.hash.substring(1);
        $("a[i++'" + myhash + "']").click();
        }

1 个答案:

答案 0 :(得分:0)

在加载时尝试查找导航元素并触发单击。

$(window).load(function() {
  if(window.location.hash) {
   // Fragment exists
   var myhash = window.location.hash.substring(1);
   $("#showcase-navigation-button-"+myhash).trigger('click');
  }
});

上面的例子只适用于一个展示。