【发布时间】:2014-03-24 19:22:44
【问题描述】:
在此链接中:
http://www.contactarte.com.pe/test/page1.html
我想知道是否可以在此页面中单击例如 SLIDE4 按钮并转到显示滑块中的幻灯片 4 的下一页。
非常感谢!!
【问题讨论】:
在此链接中:
http://www.contactarte.com.pe/test/page1.html
我想知道是否可以在此页面中单击例如 SLIDE4 按钮并转到显示滑块中的幻灯片 4 的下一页。
非常感谢!!
【问题讨论】:
当然,更改您的 href 以包含一个查询字符串参数来指示幻灯片:
<a href="page2.html?slide=0">SLIDE 1</a>
<a href="page2.html?slide=1">SLIDE 2</a>
然后根据传入的查询参数改变page2上的起始幻灯片:
$('#rotating-item-wrapper').cycle({
startingSlide: (getParameterByName('slide') || 0);
});
使用以下函数提取您的查询字符串参数 (found here):
function getParameterByName(name) {
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
results = regex.exec(location.search);
return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}
【讨论】:
startingSlide 值替换为我提供的值。第三块代码是一个新函数,你应该放在 page2.html 的任何地方
startingSlide 值以包含默认值。我已经更新了答案来做到这一点。现在,startingSlide 将默认为 0,除非提供了另一个值。另外,请记住将此标记为答案。祝你好运! =D