jquery flexslider链接到特定图像

时间:2013-03-23 19:23:07

标签: hyperlink flexslider

当点击来自其他主页的链接时(如#34; www.mysite.html#slider3"),可以在flexslider中显示特定图像吗?我有一个带有textlinks的页面。如果用户点击类似&#34的链接,请转到滑块3",将显示带有flexslider的网站,并显示滑块3.

有人可以帮帮我吗?我已经阅读了这个帖子(jQuery FlexSlider - Link to specific image),但这对我不起作用,我不知道为什么。

谢谢,抱歉我的英文不好, 放弃

2 个答案:

答案 0 :(得分:2)

Flexslider提供了一个名为“startAt”的属性,该属性接受表示要首先显示的幻灯片的索引。您还可以通过将“slideshow”参数设置为false来禁用幻灯片的自动播放。如果您在创建幻灯片放映之前获取要从头开始的幻灯片参考,则可以使用这些参数。

// create a variable to store the slide index to start at.
startAtSlideIndex = 0;

// see if a tab anchor has been included in the url
if (window.location.hash != '') {

  // Set the startAtSlideIndex variable to one less than the ordinal passed
  // note: if you have more than 9 slides, this will fall down and you'll
  //       have to do some more complex string manipulation.
  //       A querystring variable might be easier, especially if you use
  //       someone else's url parser ;)
  // Important: assumes the format of the hash is '#tabN' where N is the digit we want.
  startAtSlideIndex = window.location.hash.substr(4,1)-1;
}

$("#flexslider-container").flexslider({

  // other flexslider params

  // set the flexslider startAt param to the value of the startAtSlideIndex variable
  startAt: startAtSlideIndex

});

编辑:我忘记了位置对象在我的原始答案中有一个'hash'属性。

答案 1 :(得分:1)

它又是我:-)它似乎也适用于9个以上的幻灯片:我刚刚更改了代码:

// Important: assumes the format of the hash is '#tabNN' where NN is the digit we want. startAtSlideIndex = window.location.hash.substr(4,2)-0;

谢谢和问候!