0

I try to remove the '#' from the url after removing the fragment identifier.

For example:

var myUrl = location.href; // example.com/#abc
alert(location.hash);      // #abc
location.hash = ''; 
alert(myUrl);              // example.com/#

Now i try to remove the # WITHOUT a page reload. I tried to use the replace function but when i try to remove the '#' the page will reload. Is there a solution to solve this ?

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
TJR
  • 6,307
  • 10
  • 38
  • 64
  • I don't think so... if you change the location object in any way (including assigning the same value as it already has) I believe the browser will always reload based on those changes. I might be wrong (hense a comment rather than an answer), but that's my understanding – freefaller Oct 25 '12 at 11:21
  • It can't be done. Altering the uri in the browser presents a security vulnerability. (phishing) – Matt Esch Oct 25 '12 at 11:21
  • 1
    http://stackoverflow.com/questions/352343/changing-browsers-address-bar-without-refreshing – Riz Oct 25 '12 at 11:22
  • A hashtag is a means to flag a keyword for searching on twitter. I've removed your references to them. – Quentin Oct 25 '12 at 11:30

2 Answers2

0

You should use HTML5 History API for this: http://diveintohtml5.info/history.html You won't be using hashes anymore, but you can still load pages without reloading.

gabitzish
  • 9,535
  • 7
  • 44
  • 65
0

Look at this questions:

Community
  • 1
  • 1
webdeveloper
  • 17,174
  • 3
  • 48
  • 47