什么是家当/ hashbang呢? [英] What is the shebang/hashbang for?

查看:169
本文介绍了什么是家当/ hashbang呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有除了用于制作AJAX内容抓取的谷歌任何其他用途shebangs / hashbangs?或者是它?

Is there any other use for shebangs/hashbangs besides for making AJAX contents crawlable for Google? Or is that it?

推荐答案

在URL中使用时,散列长期以来阿贾克斯发明之前一直存在。

The hash when used in a URL has existed since long before Ajax was invented.

有原本是打算作为一个页面内的参考,以一个子部分。在这方面,应,例如,具有的内容表在一个页面,其每一个将一个散列链接到同一页的一部分的顶部。当你点击这些链接,页面滚动向下(或向上)的相关标志。

It was originally intended as a reference to a sub-section within a page. In this context, you would, for example, have a table of contents at the top of a page, each of which would be a hash link to a section of the same page. When you click on these links, the page scrolls down (or up) to the relevant marker.

当浏览器接收一个​​URL用哈希在它的地址的唯一前散列发送到服务器作为一个页面请求的一部分。哈希部分保持由浏览器来处理自身和滚动页面到相关的位置。

When the browser receives a URL with a hash in it, only the part of the address before the hash is sent to the server as a page request. The hash part is kept by the browser to deal with itself and scroll the page to the relevant position.

这是什么样的哈希语法原本打算,所以这是直接回答你的问题。但我会继续一点,并解释我们是如何走到从那里到我们现在的情况......

This is what the hash syntax was originally intended for, so this is the direct answer to your question. But I'll carry on a bit and explain how we got from there to where we are now...

当阿贾克斯被发明,人们开始希望找到办法,对他们网站的单个页面,但仍然有联系,人们可以点击外获得直接相关的内容。

When Ajax was invented, people started wanting to find ways to have a single page on their site, but still have links that people could click on externally to get directly to the relevant content.

开发很快就意识到,现有的哈希语法可以做到这一点对他们来说,因为它可以在JavaScript中读取URL的哈希值。所有你需要做的则是,当它看到一个哈希(这是很容易做到)滚动停止,并且你已经有了一个位被有效地忽略浏览器的URL,但可以读取和写入的JavaScript来;适合使用Ajax使用。 ,谷歌,包括在​​它的搜索URL的哈希部分只是一个幸运的奖金开始,但已经变得非常重要,因为该技术已经变得更加的事实wides $ P $垫。

Developers quickly realised that the existing hash syntax could do this for them, because it is possible to read the URL's hash value from within javascript. All you have to do then is stop it from scrolling when it sees a hash (which is easy enough), and you've got a bit of the URL which is effectively ignored by the browser, but can be read and written to by javascript; perfect for use with Ajax. The fact that Google includes the hash part of a URL in its searches was just a lucky bonus to begin with, but has become quite important since the technique has become more widespread.

我注意到,人们在呼唤这个哈希语法认领或hashbang,但在技术上这是不正确;它只是一个哈希是相关 - 这个词hashbang的'砰'的一部分指的是感叹号('砰'是印刷业术语的话)。某些URL的哈希之后可能确实添加一个感叹号,但只有哈希是相关的浏览器;之后,该字符串是完全由该网站的作者;它可能包括一个感叹号或不为他们选择,但无论哪种方式,浏览器不会用它做任何事情。随时保持称其为hashbang或认领,如果你喜欢,但明白,只有散列具有重要意义。

I note that people are calling this hash syntax a "shebang" or "hashbang", but technically that's incorrect; it's just a hash that is relevant -- the 'bang' part of the word "hashbang" refers to an exclamation mark ('bang' is a printing industry term for it). Some URLs may indeed add an exclamation mark after the hash, but only the hash is relevant to the browser; the string after it is entirely up to the site's authors; it may include an exclamation mark or not as they choose, but either way the browser won't do anything with it. Feel free to keep calling it a hashbang or shebang if you like, but understand that only the hash is of significance.

实际的术语认领或hashbang蜗居很多进一步的,而且确实提到过#!语法,而不是在一个URL的内容。

The actual term "shebang" or "hashbang" goes back a lot further, and does refer to a #! syntax, but not in the context of a URL.

这个词的本义是当这些符号被用在一个Unix脚本文件的开头,告诉什么编程语言的脚本编写脚本处理器。

The original meaning of this term was where these symbols were used at the beginning of a Unix script file, to tell the script processor what programming language the script is written in.

所以,这确实是一个回答你的问题,你措辞的方式,但可能不是你的意思,因为它无关的网址都没有。

So this is indeed an answer to your question, the way you've worded it, but is probably not what you meant, since it has nothing to do with URLs at all.

这篇关于什么是家当/ hashbang呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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