2013-07-27 39 views
0

我使用prettyphoto js。
标准脚本是:PrettyPhoto hash链接

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/ 它的工作原理和模式打开OK。 但当我尝试打开这样的链接 http://mysite.ru/video/twd.php#id=1 nothenig发生......只加载一个页面。

+0

您是否收到错误消息? – putvande

+0

nope。 它适用于'/'和'=' ,但如果我分享此链接(例如在twitter中)与'/'链接打开模式窗口右,但与'='没有任何反应 我希望你明白我) –

回答

0
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('#','?'));