开发者

Fragment URL transformation

开发者 https://www.devze.com 2023-03-01 08:33 出处:网络
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

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

精彩评论

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