Remove sharp(#) from Crossroads.js and run without it, how do I do?

Asked

Viewed 43 times

0

Iae galera, so I use this lib to do the routes. however they come this # and even if I take, it still doesn’t work if I recharge in the browser

F5 url: www.locahost.com/home = not found F5 url: www.locahost.com/#home = found

Could someone point me to a library or help me sort it out? Thank you !

1 answer

1

As hashs (#) are patterns in these types of library, I would not recommend taking. But if you really want to take, add a Listener in the url, so you exchange the information contained there, through the Browser History API. It would look like this:

$(window).on('hashchange', function(e){
  window.history.pushState("", document.title, window.location.pathname);  
 // do something...
});

See if this works for you. Here’s the documentation from History API.

  • my question arose because Durandal js does not use '#' in the router so I needed to get something friendlier, Thanks for the answer !

Browser other questions tagged

You are not signed in. Login or sign up in order to post.