在不依赖哈希值更改的情况下是否支持带有ajax的浏览器后退按钮? [英] Support browser back-button with ajax without relying on a hash change?

查看:127
本文介绍了在不依赖哈希值更改的情况下是否支持带有ajax的浏览器后退按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在使用jQuery BBQ插件来启用Bowser导航按钮,但是我有一个问题,如果用户为其中一个页面保存了书签,请说...

I'm currently using the jQuery BBQ plugin to enable the bowser navigation buttons to work, but I have a problem in that if a bookmark is saved by a user for one of the pages, say...

www.mysite.com/#page1

当用户通过书签返回时,必须首先加载整页...

when the user returns via the bookmark the full page has to first load...

www.mysite.com/

在将URL的哈希部分用于进行Ajax回调以完成页面之前.

before the hash part of the url can be used for the ajax call back to complete the page.

为解决该问题,我尝试在对主页的所有url调用中仅创建一个骨架"页面,以便通过ajax提取所有内部"内容,但这似乎不是一个很好的解决方案.

To address the problem I've tried creating only a 'skeleton' page on all url calls to the main page so that all 'inner' content is fetched via ajax, but this doesn't seem a great solution.

有人知道不使用哈希"方法支持后退按钮历史记录等"的任何方法/插件吗?

Does anyone know of any methods/plugins that do not use the 'hash' method to support 'back-button history etc?

推荐答案

防止双页加载的唯一解决方案是使用

The only solution to prevent that double page load is to use the HTML5 History API, which allows you to modify the URL directly, rather than having to deal with hashes.

由于HTML5历史记录API相对较新,因此所有浏览器对它的支持方式都不同.您可以使用 History.js 来标准化浏览器之间的功能.

As the HTML5 History API is relatively new, all browsers support it differently. You can use History.js to normalise the functionality between browsers.

要了解有关哈希问题的更多信息,以及哈希与HTML5历史记录API的比较方式,请阅读

To learn more about the problem you are having with hashes, and how hashes compare with the HTML5 History API, read this article.

这篇关于在不依赖哈希值更改的情况下是否支持带有ajax的浏览器后退按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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