0

Possible Duplicate:
What's the shebang/hashbang (#!) in Facebook and new Twitter URLs for?

I can't help noticing many websites have #! mark in their page addresses like this:www.this_is_not_really_a_link.com/#!/something_else.And I am wondering what's that #! for.You can just use www.this_is_not_really_a_link.com/something_else,right?

Is it just a preference or is there something more to this?I suspect the later because I see it in more than just one site.Can anyone help explain this?

Thanks.

Community
  • 1
  • 1
Gnijuohz
  • 3,294
  • 6
  • 32
  • 47
  • I have to admit it's a duplicate.But i did search for it in the web first.:) hope someone can close it for me. – Gnijuohz Feb 26 '12 at 00:59

2 Answers2

3

The # starts an HTML anchor. There is a huge difference between domain.tld/foo and domain.tld/#foo. The latter will jump to the anchor "foo" on the index page of domain.tld, while the former will request the index page from directory "foo" on domain.tld.

This kind of URL modification is mostly used to properly deal with using the browser history and direct links when building a page that relies heavily on AJAX requests.

Consider having a page with three tabs than you can switch between without reloading the website (because it's using JavaScript). If you now want to link somebody to a certain tab, you can only give him the address to the main page, which will show the default tab, not the one you meant. By adding the tab name to the URL on every switch the page can identify which tab to show when the page is called directly.

Till Helge
  • 9,253
  • 2
  • 40
  • 56
1

I asked this question after I searched a little,but obviously not enough.As @Don Roby pointed out this is a duplicate.You can find that question here What's the shebang/hashbang (#!) in Facebook and new Twitter URLs for?.In fact this is exactly what i asked this question for.It's better asked there and has some wonderful answers there.

In short,! is added in web sites intensive on AJAX for the sake of search engines.

Go see that question and its answers.This question really should be closed.

And thank @Till very much.

PS: It seems using #! is not exactly a good practice,though it's kind of cool.Here is a post about why :Breaking the Web with hash-bangs

Community
  • 1
  • 1
Gnijuohz
  • 3,294
  • 6
  • 32
  • 47