【问题标题】:PrettyPhoto hash linkPrettyPhoto 哈希链接
【发布时间】:2013-07-27 17:17:15
【问题描述】:

我使用漂亮的 js。
标准脚本是:

function setHashtag(){
    if(typeof theRel == 'undefined') return;
    location.hash = theRel+'/'+rel_index+'/';
};

如果我将其更改为:

function setHashtag(){
    if(typeof theRel == 'undefined') return;
    location.hash = theRel+'='+rel_index;
};

身份证不起作用。为什么?

显然,如果我使用这样的 URL -

http://mysite.ru/video/twd.php#id/1/ 它有效,并且模态打开正常。 但是当我尝试打开这样的链接时 http://mysite.ru/video/twd.php#id=1 nothenig 发生...只加载一个页面。

【问题讨论】:

  • 不。 '/' 和 '=' 可以正常工作,但如果我分享此链接(例如在 twitter 中),带有 '/' 的链接会打开模态窗口,但使用 '=' 没有任何反应,我希望你能理解我)

标签: jquery prettyphoto


【解决方案1】:
hashIndex = getHashtag();
hashRel = hashIndex;
hashIndex = hashIndex.substring(hashIndex.indexOf('=')+1,hashIndex.length);
hashRel = hashRel.substring(0,hashRel.indexOf('='));

hashtag = (url.indexOf('?id') !== -1) ? decodeURI(url.substring(url.indexOf('?id')+1,url.length)) : false;

location.hash = theRel + '=' + rel_index;
history.pushState(0, 0, location.hash.replace('#','?'));

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-06-27
    • 2012-05-06
    • 1970-01-01
    • 2012-11-10
    • 2021-11-26
    • 1970-01-01
    • 2014-04-27
    • 1970-01-01
    相关资源
    最近更新 更多