How do I use www.domain.org/#!/topic/item style URLs and what are they called?

人走茶凉 提交于 2019-12-05 19:50:54

The reason why Twitter and some popular sites use hash in the address, is that it gives the website the ability to use the Back and Forward button on a content that is dynamically loaded using Ajax. You don't really have to do anything on the server-side, the trick is to catch the address change on the client-side.

There is a popular plugin for jQuery called jQuery History. - http://tkyk.github.com/jquery-history-plugin/ which does the job for you, but you would have to load the content from the server using Ajax and display it in some container on your website.

One note, the ! next to the hash is a way to make search engines be able to crawl your website. More about that on http://code.google.com/web/ajaxcrawling/docs/getting-started.html

What you usually do is to pick up the window.location.hash, and pass it as a parameter to the server in an AJAX request.

There's the window.onhashchange event for finding out when it's changed (hence when to issue a new AJAX request), but not all browsers implement it, so for now you're better off just writing a javascript interval that continuously checks if the hash has changed.

They are used by dynamic web pages as you already said. There are many ways to handle such url requests on the server side. The form with the exclamation mark is used for SEO I believe.

see http://code.google.com/intl/de-DE/web/ajaxcrawling/docs/specification.html.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!