开发者

Fragment URL transformation

I have the BBQ plugin working already, so this is just a cosmetic change. I have no idea how to transform the URL from /index.html#pages/index开发者_如何学运维.html to just /index.html#index

It's basically a fragment transformation I guess, but am very new to JS. Any thoughts?


You can access the hash just using window.location.hash and it returns a string so you can do whatever string manipulation you like on it. For Example:

var temp = window.location.hash; // == #pages/index.html
temp = temp.replace("pages/","").replace(".html","");
window.location.hash = temp; //sets the hash to #index
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜