Remove the crossroads.js sharpen (#) and run without it, how do?

0

Ie guys, so I use this lib to do the routes. but they do not even come with this # and even if I take it, it still does not work if I reload in the browser

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

Can anyone point me to a library or help me solve this? thank you !

    
asked by anonymous 10.11.2016 / 04:07

1 answer

1

Hash (#) are defaults in these library types, I would not recommend taking them. But if you really want to remove it, 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 is the History API documentation.

    
10.11.2016 / 11:28