AJAX和后退按钮 [英] AJAX and back button

查看:117
本文介绍了AJAX和后退按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何保存历史与AJAX是多么的GitHub或者google +做。我使用jQuery,我不希望使用某种形式的黑客攻击,如#和#的!招数,因为如果我这样做,我需要改变我的整个项目,使我的生活变得更加复杂?

How can I save history with AJAX just how github or google+ do. I use jQuery and I do not want to use some kind of hack like the # and #! tricks, because if I do, I'll need to change my whole project and make my life much more complicated?

推荐答案

基本上有两种选择,当谈到AJAX和历史。

There are basically two options when it comes to AJAX and history.

  1. 该#方法(这是不是黑客攻击的BTW)。既然你不希望一个你只能选择2左右。

  1. The # method (which isn't a hack btw). Since you don't want that one you only have option 2 left.

使用PushState。这是Facebook的不同,GitHub和其他几个人使用的。它不支持所有的浏览器,虽然,如果你想完整的跨浏览器兼容,你将不得不使用一种能降解为选项1。

Use PushState. This is what Facebook, GitHub and a few others use. It's not supported by all browsers though and if you want complete cross-browser compatibility you will have to use a system which can degrade to option 1.

要实现这是一个非常简单的方法是Backbone.js的Router类。

A very simple way to implement this is Backbone.js Router class.

这篇关于AJAX和后退按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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