0

How do get the hash url to output something cleaner? Its doing this:

domain.com/#/page/1

When I want it to do this:

domain.com/page/1

 $(document).ready(function(){ var newHash = ''; $('#wrapper a').live('click', function(e){ if (this.hostname && this.hostname == location.hostname) { e.preventDefault(); var link = $(this).attr('href'); window.location.hash = link; } }); $(window).bind('hashchange', function() { newHash = window.location.hash.substr(1); $('#content').fadeOut(100).load(newHash + ' #contentInner', function(){ $('#content').fadeIn(100); }); }); }); 
2
  • Those are two completely different URLs. They point to different resources. The first points to the domain.com default index, the second to /page/1 of domain.com. Everything before the hash describes the resource name and optional parameters, and everything after is an anchor with the resource that is usually handled by the client. Commented Jul 18, 2011 at 20:48
  • 1
    If I'm understanding you correctly, you need the HTML5 history API to accomplish this. Commented Jul 18, 2011 at 20:48

3 Answers 3

2

Try :

var url = "domain.com/#/page/1"; var noHash = url.split("/#").join(""); 
Sign up to request clarification or add additional context in comments.

Comments

1

That's what a hash is supposed to look like - the # portion is the hash. If you don't want a hash in your url, then do:

window.location = link; 

instead.

Comments

0
if (location.href.indexOf("#") > -1) { location.assign(location.href.replace(/\/?#\//, "/")); } 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.