简体   繁体   English

更改浏览器URL和页面内容而无需重新加载和使用片段

[英]Change browser URL and page content without reload and without using fragments

I'm well aware of the technique of using URL fragments to track state on an AJAX powered webpage, but lately I've noticed a lot of sites that are doing something similar but without fragments. 我很清楚使用URL片段来跟踪AJAX支持的网页上的状态的技术,但是最近我注意到很多站点在做类似的事情但没有片段。

The picture viewer in the latest version of Facebook for example operates this way. 例如,最新版本的Facebook中的图片查看器以这种方式运行。 The left and right navigation buttons are simple links with no fragments that when clicked change the browsers URL without doing a full page load. 左侧和右侧导航按钮是简单的链接,没有片段,单击这些片段可以更改浏览器的URL,而无需加载整个页面。

Another example is GitHub's repository browser , each of the files/folders is a simple link that changes the page state and browser URL without reloading or using page fragments. 另一个示例是GitHub的存储库浏览器 ,每个文件/文件夹都是一个简单的链接,可更改页面状态和浏览器URL,而无需重新加载或使用页面片段。

Can anyone explain, or point me to an explanation of how this works? 谁能解释一下,或让我指出这是如何工作的? I've done some searching, but there is so much content on using fragments that I haven't been able to find anything. 我已经做了一些搜索,但是使用片段的内容太多了,我什么都找不到。

They are using new HTML5 History API. 他们正在使用新的HTML5历史记录API。 I think this is what you want. 我想这就是你想要的。 check the menu items in this page http://tinywall.info/demos/html5-history-api/menu1.php 检查此页面上的菜单项http://tinywall.info/demos/html5-history-api/menu1.php

The tutorial to implement is right here : http://t.co/M4RvnvoQ 要实施的教程就在这里: http : //t.co/M4RvnvoQ

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM