How Does Github Do pushState Without Hash Tags?

大兔子大兔子 提交于 2019-12-18 10:29:35

问题


I've been researching the best way to utilize HTML5's history api aka psuhState with a proper fallback for HTML4 browsers.

Github uses the history api for its tree browsing (the following link is just an example, not the library github uses):

https://github.com/browserstate/History.js/

What I can't figure out is how they handle this functionality for HTML4 browsers such as Firefox 3.5?

I've looked at, specifically, history.js (linked above) to handle this sort of thing. But it requires a hash # implementation for HTML4 browsers which I'd like to avoid.

If you visit Github and browse a directory tree using an HTML4 browser, it looks identical to an HTML5 browser (the url state, that is).

If I disable JavaScript in FF3.5, a URL which previously looked like this:

https://github.com/browserstate/history.js/tree/master/tests

now looks like this:

https://github.com/browserstate/history.js/tree/a32e91aa1fe5909a29abb690a37f6c129e98068e/tests

Any thoughts?


回答1:


GitHub uses http://pjax.heroku.com/

For browsers that don't support pushState it simply degrades to normal old boring full-page-load behaviour.




回答2:


Responsive web design from the future is a 96 slide presentation from Kyle Neath, a designer that works at GitHub, that might help you.

pushState. replaceState. Hashbangs. AJAX. PJAX. Beets. Bears. Battlestar Galactica.

Responsive web design is about a lot more than the size of your screen. This talk is about about how GitHub handles links, the url bar, partial page updates, and explains why I think the HTML5 history API is the most important thing to happen to front end development since Firebug.



来源:https://stackoverflow.com/questions/6560570/how-does-github-do-pushstate-without-hash-tags

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