实现github.com文件无缝文件导航 [英] Implement github.com file seamless file navigation

查看:86
本文介绍了实现github.com文件无缝文件导航的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚注意到浏览github存储库时最近的一次更改。选择文件或文件夹时,新文件将滑入并推出旧文件。这很容易与jquery一起使用,但真正不同的是URL本身实际上发生了变化,因此书签仍然有用。我一直在努力为我正在处理的图书导航网站创建这个,但是如果没有整页刷新就无法更新网址。关于github如何做到这一点的任何想法?

I just noticed a recent change when browsing github repositorys. When you select a file or folder, the new file slides in and pushed the old file out. This is easy enough to do with jquery, but what's really different is that the URL itself actually changes so that bookmarks still work. I've been struggling to create this for a book navigating site I'm working on but haven't been able to update the url without a full page refresh. Any ideas on how github does this?

推荐答案

它正在使用新的HTML5 API history.pushState / history.replaceState来做到这一点(所以它只适用于现代浏览器)。

It's using the new HTML5 API history.pushState/history.replaceState for doing this (so it only works in modern browsers).

请参阅 https:// developer .mozilla.org / en / DOM / Manipulating_the_browser_history#Adding_and_modifying_history_entries 了解更多详情。

如果你想为所有浏览器提供解决方案,那么你必须坚持修改片段(#后面的位)

If you want a solution for all browsers, then you have to stick to modifying the fragment (the bit after the #)

这篇关于实现github.com文件无缝文件导航的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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