如何在不重载和# hack的情况下更改窗口的位置?

时间:2022-04-10 05:07:00

At first I thought that hash hack is a requirement, however judging from the recent updates from facebook, I am thinking otherwise.

一开始我认为哈希哈克是一种要求,但从最近facebook的更新来看,我的想法与此相反。

The original hash hack (I am not sure if this is the correct term) is that by changing location.hash, one may save a state in the URL without refreshing the page. That is extensively used by Google's apps, and Facebook, and lately #NewTwitter. However today I noticed that Facebook no longer have this "#" if you use a "modern" browser - like chrome or firefox. I double checked that they are not reloading by using developer tools and firebug respectively.

最初的哈希哈克(我不确定这是否是正确的术语)是通过改变位置。哈希,可以在URL中保存状态而不刷新页面。这被谷歌的应用程序、Facebook和最近的twitter广泛使用。然而,今天我注意到,如果你使用的是“现代”浏览器,比如chrome或firefox, Facebook就不再有“#”了。我再次检查它们没有通过使用开发人员工具和firebug重新加载。

With a minimal search in *, the closest one to the solution is using Flash - however I disabled Flash and facebook.com still works like a charm. Judging from the coverage in chrome 8 dev and firefox 4 beta, I wonder that could be related to HTML5-era APIs, but the code in Facebook is not of my capacity to debug to find out what they did.

在*中只做了很少的搜索,最接近解决方案的是使用Flash——但是我禁用了Flash和facebook.com,它仍然像一个魔咒。从chrome 8开发和firefox 4 beta测试的覆盖率来看,我想知道这是否与html5时代的api有关,但是Facebook中的代码并不是我调试的能力,无法找出他们做了什么。

Since this is like the first question I ask here, I wonder if any of you may have already solved this problem.

既然这是我在这里问的第一个问题,我想知道你们中是否有人已经解决了这个问题。

Thanks guys.

谢谢你的家伙。

P.S. Doesn't work on IE8, haven't tested on IE9 beta.

P.S.没有在IE8上工作,也没有在IE9测试版上测试过。

1 个解决方案

#1


20  

Facebook is using the history api in HTML5. From this blog post you can see how this works. Basically they are making calls like the one below to change the url without reloading the page.

Facebook正在HTML5中使用历史api。从这篇博文中你可以看到这是如何工作的。基本上,他们会像下面这样打电话,在不重载页面的情况下更改url。

window.history.pushState("object or string", "Title", "/new-url");

Here is the HTML5 working draft spec about it: http://www.whatwg.org/specs/web-apps/current-work/multipage/history.html#the-location-interface

这里是HTML5工作草案规范:http://www.whatwg.org/specs/web- apps/currentwork/history.html # -location-interface。

Sadly, IE9 does not support this api. New versions of Chrome and FF have full support.

遗憾的是,IE9不支持这个api。新版本的Chrome和FF完全支持。

#1


20  

Facebook is using the history api in HTML5. From this blog post you can see how this works. Basically they are making calls like the one below to change the url without reloading the page.

Facebook正在HTML5中使用历史api。从这篇博文中你可以看到这是如何工作的。基本上,他们会像下面这样打电话,在不重载页面的情况下更改url。

window.history.pushState("object or string", "Title", "/new-url");

Here is the HTML5 working draft spec about it: http://www.whatwg.org/specs/web-apps/current-work/multipage/history.html#the-location-interface

这里是HTML5工作草案规范:http://www.whatwg.org/specs/web- apps/currentwork/history.html # -location-interface。

Sadly, IE9 does not support this api. New versions of Chrome and FF have full support.

遗憾的是,IE9不支持这个api。新版本的Chrome和FF完全支持。