javascript - HTML:在不重新加载页面的情况下更改 URL?

标签 javascript html pushstate

查看此链接:

http://google.blogspot.com/view/timeslide

然后单击该帖子,您可以看到 URL 正在更改但没有 # 或类似内容,它的更改就像页面正常加载一样,但内容的更改就像使用 AJAX 构建一样。

这发生在 Chrome 10 的最新稳定版本中,但对于 Firefox 3.6,它使用带有哈希的旧方法:)

这怎么可能,这是一个新的 HTML5 特性还是什么?

最佳答案

pushState :

window . history . pushState(data, title [, url ] )

    Pushes the given data onto the session history, with the given title, and, if provided, the given URL...

the user agent must run the following steps...

Add a state object entry to the session history, after the current entry, with cloned data as the state object, the given title as the title, and, if the third argument is present, the absolute URL that was found earlier in this algorithm as the URL of the entry.

Update the current entry to be the this newly added entry...

关于javascript - HTML:在不重新加载页面的情况下更改 URL?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5525636/

相关文章:

javascript - 向溢出容器的内容添加渐变淡入淡出

javascript - 使用 jQuery 替换 Url 中的值

jquery - Internet Explorer 中的 History.js 哈希回退和 PushState 问题

javascript - Nodejs 基于不活动使 cookie 过期

javascript - 服务器端事件 - 如何将参数传递给服务器端脚本?附加查询字符串?

javascript - 无按钮自动日期计算器

html - 单击 TD 对象的超链接

css - float CSS 问题 - 类似于 Windows 8 的磁贴

html - IE10 中的淡入淡出线(渐变)

jquery - 在不重新加载页面的情况下更新浏览器的 URL