如何重写URL不刷新,像GitHub.com [英] How to rewrite URL without refresh, like GitHub.com

查看:107
本文介绍了如何重写URL不刷新,像GitHub.com的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在浏览GitHub.com并查看源存储库时,我注意到,你点击一个文件,源$ C ​​$ C幻灯片和URL的变化,但它不会出现犹如页面刷新。有谁知道如何做到这一点?我已经看到了这个加上#号完成的,特别是在创建Flash网站的时候,但我从来没有见过这样做得比较像GitHub上是做的方式,而不#。

I was browsing GitHub.com and I noticed when looking at the source for a repository, and you click on a file, the source code slides in and the URL changes, but it doesn't appear as if the page has refreshed. Does anyone know how this is done? I've seen this done with the # sign, especially when creating Flash sites, but I've never seen this done quite like the way GitHub is doing it, without the #.

下面是一个例子:
https://github.com/jquery/jquery

点击的文本文件,比如.gitattributes之一,然后在面包屑点击了jQuery明白我的意思。

Click on one of the text files like .gitattributes then click on jQuery in the breadcrumb to see what I mean.

推荐答案

XMLHtt prequest上使用Chrome浏览器/ WebKit浏览器客户端无需页面清爽获取服务器端资源和内容是动态加载和动画可以在该内容被追加被钩住英寸

XMLHttpRequest is used on the client-side in Chrome/Webkit browsers to fetch server-side resources without page refreshing, and content is dynamically loaded in, and animations can be hooked in during that content being appended.

我不知道究竟为什么只有Chrome浏览器由阿贾克斯的目标,因为通常当AJAX以同样的方式被应用(如Twitter),井号改变。

I'm not sure exactly why only Chrome is targeted by the ajax, as usually the hash mark changes when ajax is applied in the same manner ( like twitter ).

对于URL动态变化的,我相信所有这一切做的是 location.href 更新。 关于第二个想法,也可能是一些新的HTML5功能,只有Chrome支持。

For the url changing dynamically, I believe all that's done is location.href is updated. On second thought, it could be some new HTML5 feature that only chrome supports.

这篇关于如何重写URL不刷新,像GitHub.com的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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