0

我为我的网站设置了一个深度链接,除了前进和后退按钮外,它都可以工作,我有点不确定如何更新我所做的事情。网址会更改,但内容不会更改,除非您点击刷新。

这是它工作的一个例子:http ://www.klossal.com/index2.html#color_dance

这是代码:

        // taked anchor from browser i.e '#bow' , '#bow-003'
        var id = window.location.hash;

        // check is it valid anchor
        if (id.match("#") != null | id.match("#undefined") != null) {


                $(id).ready(function () {
                    $(id).trigger("click");
                });
            }
        $(".iso").click(function () {
            window.location.hash = $(this).attr("id");
        });
4

1 回答 1

1

$(window).on('hashchange',function() { var id = window.location.hash;

    // check is it valid anchor
    if (id.match("#") != null | id.match("#undefined") != null) {


            $(id).ready(function () {
                $(id).trigger("click");
            });
        }

});

于 2013-01-16T00:55:15.577 回答