0

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?

James Allardice
  • 164,175
  • 21
  • 332
  • 312
Pepe
  • 1

1 Answers1

1

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
LeRoy
  • 3,195
  • 4
  • 26
  • 23
  • @Pepe Did you set `hashchange` event? – cem Apr 28 '11 at 00:36
  • You can. This is just the code to manipulate the hash. You didn't mention onhashchange in your question? If it is you should explain how you want to use it. I found some info about onhashchange for you and I can change my answer to include it once I know what you expecting. It looks like jquery has a good onhashchange event. Some info here - http://stackoverflow.com/questions/680785/on-window-location-hash-change – LeRoy Apr 28 '11 at 13:11