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
});
编辑:我忘记了位置对象有一个'哈希'属性在我原来的答案。
嗨Michael, 感谢您的回答!我很抱歉这么晚回答。由于这不是我的主要工作,我甚至无法测试它。现在我会弥补并再次报告我。我有一个关于你的代码的问题:什么意思是“(4,1)”? 不幸的是,我有超过9张幻灯片...我有什么要更改代码? 非常感谢! – CeDe 2013-06-16 13:21:33
哇!它很棒!再次感谢你!我只用了几张图片就尝试过了,但现在我想让它使用超过9张图片。请你能告诉我我必须做什么吗? – CeDe 2013-06-16 18:25:04