如何重写的Facebook页面在浏览器地址栏中的来源网址? [英] How does facebook rewrite the source URL of a page in the browser address bar?
问题描述
转到 http://www.facebook.com/facebook?v=wall ,然后点击信息选项卡。内容将被加载,并在地址栏现在变成 http://www.facebook.com/facebook?v=info < /一>,但网页不刷新。
Go to http://www.facebook.com/facebook?v=wall, then click on the info tab. The content will be loaded, and the address bar now becomes http://www.facebook.com/facebook?v=info but the webpage didn't reload.
起初,我认为这是阿贾克斯,但我的问题是,你如何改变地址栏没有重新加载?我知道我可以改变使用JS但查询字符串(?V =墙),锚(#wall)怎么样?
At first I think it is Ajax, but my question is, how do you change the address bar without reloading? I know I can change anchor (#wall) using JS but querystring (?v=wall), how?
推荐答案
它使用HTML5的新的<一个href="http://www.w3.org/TR/html5/history.html#dom-history-pushstate"><$c$c>history.pushState()$c$c>功能让网页伪装成处于不同的网址,从它最初是牵强。
It's using HTML5's new history.pushState()
feature to allow the page to masquerade as being at a different URL to that from which it was originally fetched.
这似乎只由WebKit的目前支持的,这就是为什么我们其余的人都看到?V =墙#!/ Facebook的?V =信息
而不是对?V =信息
。
This seems only to be supported by WebKit at the moment, which is why the rest of us are seeing ?v=wall#!/facebook?v=info
instead of ?v=info
.
该功能允许动态加载的页面进行正确书签,JS-支持和非JS-支持用户代理之间的交换等。因为如果你作为一个JS用户链接有人?V =墙#!/ Facebook的?V =信息
和他们的浏览器不支持JS和XMLHtt prequest,该网页将不会为他们工作。该#!
也被用来作为小费给搜索引擎,下载非Ajax版本。
The feature allows dynamically-loaded pages to be properly bookmarked, exchanged etc between JS-supporting and non-JS-supporting user agents. Because if you as a JS user linked someone to ?v=wall#!/facebook?v=info
and their browser didn't support JS and XMLHttpRequest, the page wouldn't work for them. The #!
is also used as a tip to search engines to download the non-AJAX version.
这篇关于如何重写的Facebook页面在浏览器地址栏中的来源网址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!