When using Ajax History and Bookmark, it is always useful to use "#!". instead of just "#"?

Facebook makes Ajax history (Back and Forward buttons) and bookmarks using #! , not just # in the URL. This is always a good idea, because I thought that a normal anchor could interfere with the Ajax history mechanism to trigger it when processing a normal anchor.

So, the Ajax History function will only process the hash part when it sees #! , not just # .

And uses ! compatible with major browsers? If Facebook uses ! It is suggested that it can be pretty well supported.

+4
source share
2 answers

See Google Creating AJAX Crawlable apps for a possible use case (I don't know why Facebook used this snippet).

+5
source

Update: This answer has been superseded by this article . It discusses issues with Hashbang (#!), Hashes (#) and the HTML5 History API (pushState, popState) and solutions.

As for the usability on your website, it does not matter, and you can use whatever you like.

As for search engine optimization, its presence and absence both provide different opportunities for reduction.

For example, Facebook uses! according to Google Proposal for building Ajax Crawlable apps . Adding! will tell google that it should listen to this ajax request and add this url to the search engine results. This is great for sites that have already implemented ajax, since all you have to do is add !.

The disadvantage of this is that it solves the problem just to make your ajax crawlable. It does not solve the problem:

  • Saving URLs for Ajax and Non-Ajax Users. For instance. you can end up with www.facebook.com/profile.php?pid=123#!profile.php?pid=123
  • Saving the website by non-Ajax users.
  • Storing URLs is the same for Ajax and Non-Ajax users.
  • Some very complicated server-side changes are required to shield and translate states for query strings.
  • It is incompatible with the new HTML5 PopState functionality, which is designed to really solve these problems.

For sites that do not currently use ajax for everything, because of the above issues, it is much better NOT to use Google Proposal, as this is only a workaround for sites like facebook that were crazy and needed a desperate SEO solution. There are alternatives that solve more of these problems (and now available HTML5 PopState can solve all problems). One such alternative is jQuery Ajaxy (as seen on balupton.com ), which works by simply updating your site in the ajax application, while preserving the experience for rich and interactive Ajax-Enabled and continuing to work great for Ajax-Disabled users.

+5
source

All Articles