如何改变浏览器地址栏没有刷新页面 - HTML / Javascript的 [英] How to change browser address bar without reloading page - HTML/Javascript

查看:289
本文介绍了如何改变浏览器地址栏没有刷新页面 - HTML / Javascript的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
  <一href="http://stackoverflow.com/questions/4973777/how-does-github-change-the-url-but-not-the-reload">How并GitHub上更改URL,但不重装?

乡亲

我注意到,Github.com不浏览库时,强迫用户下载的网页,而是为了刷新页面内容使用AJAX。

I have noticed that Github.com does not force users to download webpages when browsing repositories, but instead uses AJAX in order to refresh the page content.

Github上也改变了浏览器的地址栏的实际地址再presenting内容。我不知道如何在没有实现这个使用URL中##标签。

Github also changes the browser address bar to the real address representing the content. I have no idea how to implement this if not by using # hashtags within the url.

简而言之: github上使用AJAX加载新的网页,而无需使用#标签。他们是如何做到这一点?

In short: github uses ajax to load new webpages, without using hashtags. How do they accomplish this?

任何想法?

推荐答案

使用:

window.history.pushState("string", "Title", "newUrl");

这是新的HTML 5。

This is new in HTML 5.

您的URL将变成无的newURL重新加载页面。

Your url will change to newUrl without reloading the page.

注:该方法标题ARG不会改变HTML页面的标题。这是用来命名的浏览器历史记录的页面,以防你走回来,然后向前走。

Note: title arg in the method will not change the Title of the html page. This is used to name the page in the browser history, incase u go back and then go forward.

这篇关于如何改变浏览器地址栏没有刷新页面 - HTML / Javascript的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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