Jssor基于查询字符串加载特定幻灯片

时间:2014-10-03 14:16:59

标签: jssor

将滑块配置为视频库,我希望从其他页面访问特定视频。 是否可以基于查询字符串配置滑块以显示特定幻灯片?

2 个答案:

答案 0 :(得分:0)

您可以指定$ StartIndex选项。

var slideIndex = parseInt(getParameterByName("elt") || "0");

var options = {
    ...
    $StartIndex: slideIndex    //specify slide index to display at the begining, default value is 0.
    ...
};

var jssor_slider1 = new $JssorSlider$("slider1_container", options);

答案 1 :(得分:0)

我使用以下方法检索查询字符串

    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, " "));
    }

然后创建滑块

        var jssor_slider1 = new $JssorSlider$("slider1_container", options);
        var slideIndex = getParameterByName("elt");
        (slideIndex != "") ? jssor_slider1.$GoTo(slideIndex) : jssor_slider1.$GoTo(0);