为什么新的网络的Dropbox可以更改,恕不刷新页面的网址是什么? [英] Why the new web Dropbox can change the URL without page refresh?

查看:188
本文介绍了为什么新的网络的Dropbox可以更改,恕不刷新页面的网址是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
  <一href="http://stackoverflow.com/questions/4089178/how-to-change-the-url-displayed-in-the-browser-without-leaving-the-page">How更改浏览器中显示的网址,而不必离开页面
  <一href="http://stackoverflow.com/questions/4664166/how-to-do-awesome-refreshless-page-changes-like-github">How做这样的GitHub
真棒refreshless页变化   <一href="http://stackoverflow.com/questions/4979581/change-browser-url-and-page-content-without-reload-and-without-using-fragments">Change不重装,不使用片段浏览器的URL和页面内容

Possible Duplicate:
How to change the URL displayed in the browser without leaving the page
How to do awesome refreshless page changes like GitHub
Change browser URL and page content without reload and without using fragments

这是惊人的!新的Dropbox网页版能做到这一点!它会做Ajax请求,并更改URL,但页面将不会刷新!(不改变哈希)

It is amazing! The new Dropbox web version can do this! It will do ajax request and change the url,but the page will not refresh!(not change the hash)

的URL会从 https://www.dropbox.com/home/ 以< A HREF =htt​​ps://www.dropbox.com/home/Public相对=nofollow> https://www.dropbox.com/home/Public 。

您可以尝试一下。

如何实现的呢?

推荐答案

他们使用的是HTML5 Pushstate:

They're using HTML5 Pushstate:

http://badassjs.com/post/840846392/location-hash-is-dead-long-live-html5-pushstate

什么是pushState?

What is pushState?

历史对象获得两个新的方法,pushState和放大器; replaceState,使我们能够改变 浏览器的当前位置,而不进行HTTP请求。这些新的位置存储在所述 浏览器历史记录,因此,无论是前进和后退按钮正常工作。

The history object gains two new methods, pushState & replaceState, that allow us to change the current location of the browser without making an HTTP request. These new locations are stored in the browsers history so that both the back and forward button work as expected.

 history.pushState({foo: "bar"}, "foo page", "/foo")

这篇关于为什么新的网络的Dropbox可以更改,恕不刷新页面的网址是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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