#!哈希标签和感叹号链接为文件夹? [英] #! hashtag and exclamation mark in links as folder?

查看:123
本文介绍了#!哈希标签和感叹号链接为文件夹?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何让页面显示为grooveshark页面

http:// grooveshark。 com /#!/ popular

是否有教程或知道如何通过jQuery或JavaScript显示页面的方法?

how i can make my pages show like grooveshark pages
http://grooveshark.com/#!/popular
is there a tutorial or something to know how to do this way for showing page by jQuery or JavaScript?

推荐答案

URL中的散列和感叹号称为hashbang,通常用于JavaScript应用程序,其中JavaScript负责实际加载页面。散列之后的内容永远不会发送到服务器。例如,如果你有url example.com /#!recipes / bread 。在这种情况下,example.com中的页面将从服务器获取,这可能包含一段javascript。然后这个脚本可以从 location.hash 中读取,并在 / recipes / bread 中加载页面。

The hash and exclamation mark in a url are called a hashbang, and are usualy used in web applications where javascript is responsible for actually loading the page. Content after the hash is never sent to the server. So for example if you have the url example.com/#!recipes/bread. In this case, the page at example.com would be fetched from the server, this could contain a piece of javascript. This script can then read from location.hash, and load the page at /recipes/bread.

Google也将此URL方案识别为AJAX网址,并尝试从服务器获取内容,因为它会通过JavaScript呈现。如果您打算使用此技术制作网站,请参阅 Google的AJAX抓取文档站长的。另外请记住,你不应该依赖javascript被启用,因为 Gawker学到了很难的方法。

Google also recognizes this URL scheme as an AJAX url, and will try to fetch the content from the server, as it would be rendered by your javascript. If you're planning to make a site using this technique, take a look at google's AJAX crawling documentation for webmasters. Also keep in mind that you should not rely on javascript being enabled, as Gawker learned the hard way.

hashbang在很多站点都不再使用,evenif javascript路由。这是可能的,因为所有主流浏览器都支持历史API 。为此,他们让网站上的每个路径都返回相同的Javascript,然后查看要在内容中加载的实际url。当用户点击一个链接时,JavaScript拦截点击事件,并使用历史API将新页面推入浏览器历史记录,然后加载新内容。

The hashbang is being going out of use in a lot of sites, evenif javascript does the routing. This is possible because all major browsers support the history API. To do this, they make every path on the site return the same Javascript, which then looks at the actual url to load in content. When the user clicks a link, Javascript intercepts the click event, and uses the History API to push a new page onto the browser history, and then loads the new content.

这篇关于#!哈希标签和感叹号链接为文件夹?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆