JQuery Fancybox-更改url并直接访问它

JQuery Fancybox-更改url并直接访问它,jquery,Jquery,基本上,我需要地址栏中的fancybox更改url,我有如下url: <li><a href="http://www.test.com/test/page/index" data-fancybox-href="http://www.test.com/test/page/index" id="page/index" class="list-group-item">Pages</a></li> <li><a href="http://

基本上,我需要地址栏中的fancybox更改url,我有如下url:

<li><a href="http://www.test.com/test/page/index" data-fancybox-href="http://www.test.com/test/page/index" id="page/index" class="list-group-item">Pages</a></li>
<li><a href="http://www.test.com/test/gallery/index" data-fancybox-href="http://www.test.com/test/gallery/index" id="gallery/index" class="list-group-item">Gallery</a></li>
这里的第一个问题是选择器
“id”
,如果一个id有这样的语法
id=“page/index”
,可以吗,因为当我尝试直接访问url时,它不起作用,所以我尝试了
id=“page\u index”
,它起作用了,但在url栏上看起来不好,所以我可以用任何方式获得我想要的url吗?第二,我是否可以使用另一个选择器,如
“id”

谢谢

在html5中,您可以提供您的元素

e、 g

var current_hash = '';
var thisHash = window.location.hash;
$(document).ready(function() {
    $('.list-group-item').fancybox({
        prevEffect: 'fade',
        nextEffect: 'fade',
        closeBtn: true,
        arrows: true,
        type: 'iframe',
        nextClick: true,
        padding: 15,
        helpers: {
            thumbs: {
                width: 80,
                height: 80
            }
        },

        beforeShow: function() {
            var id = this.element.attr("id")
            current_hash = id;
            if (id) {
                window.location.hash = current_hash;
            }
        },
        beforeClose : function() {
            current_hash = false;
        },
        afterClose : function() {

            if ("pushState" in history) {
                history.pushState("", document.title, window.location.pathname);
            } else {
                window.location.hash = "";
            }
        }

    });
    if (thisHash) {

        $(thisHash).trigger('click');

    }
});
<li><a href="http://www.test.com/test/page/index" data-fancybox-href="http://www.test.com/test/page/index" data-change-link="page/index" id="myIdentifier" class="list-group-item">Pages</a></li>
$('#selector').data('change-link');
$('#selector').attr('data-change-link');