页面刷新后,JavaScript幻灯片停留在同一张幻灯片上

时间:2016-07-27 09:23:07

标签: javascript jquery responsive-slides

我有一张JavaScript幻灯片,里面是gridview。我想在回发或页面刷新后留在同一张幻灯片上。 gridview都有不同的功能。

这是我的代码。

HTML:

<div class = "callbacks_container">
    <div class="rslides callbacks callbacks1" id="slider3">

        <div class = "grid-slide">
            <div class = "prg-dte">
                <asp:Label ID="Label1" class = "srch-res" runat="server" ></asp:Label>
            </div>

            <div class = "table-grid">
                <asp:GridView ID="GridView1" class = "grd-view table table-hover table-striped" OnRowDataBound="GridView1_RowDataBound"  OnSelectedIndexChanged="Gridview1_OnSelectedIndexChanged"  runat="server">
            </asp:GridView>
        </div>

        <div class = "grid-slide">
            <div class = "prg-dte">
                <asp:Label ID="Label2" class = "srch-res" runat="server" ></asp:Label>
            </div>

            <div class = "table-grid">
                <asp:GridView ID="GridView2" class = "grd-view table table-hover table-striped" OnRowDataBound="GridView2_RowDataBound"  OnSelectedIndexChanged="Gridview2_OnSelectedIndexChanged"  runat="server">
            </asp:GridView>
        </div>

    </div>
</div>

JavaScript的:

$(function() {
    $("#slider3").responsiveSlides({
        auto: false,
        pager: false,
        nav: true,
        speed: 500,
        namespace: "callbacks",
        before: function() {
            $('.events').append("<li>before event fired.</li>");
        },
        after: function() {
            $('.events').append("<li>after event fired.</li>");
        }
    });
});

1 个答案:

答案 0 :(得分:0)

如果使用了responseSlides,您可以获取并设置当前幻灯片,您可以使用cookie来记忆当前幻灯片,并在每次页面加载时从该cookie中读取。

此答案向您展示如何获取当前幻灯片: https://stackoverflow.com/a/23815701/2413794