和浏览器后退按钮

和浏览器后退按钮

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

问题描述

我在 www.darknovagames.com 上运行基于浏览器的游戏.最近,我一直在努力用 CSS 重新格式化网站,试图让它的所有页面都根据 HTML 标准进行验证.

I run a browser based game at www.darknovagames.com. Recently, I've been working on reformatting the site with CSS, trying to get all of its pages to verify according to the HTML standard.

我一直在玩弄这个想法,即在左侧 AJAX 页面中使用导航菜单(而不是每次将用户带到单独的页面,需要重新加载标题和导航栏,这几乎永远不会改变) 而且我知道如果这样做,我可能会破坏浏览器中的前进/后退按钮.我想我的问题是,我应该继续对网站进行 AJAX 处理,从而要求用户使用网站导航来玩游戏,还是应该让网站保持现状,并使用标准超链接和其他东西进行导航?

I've been toying with this idea of having the navigation menu on the left AJAX the pages in (rather than taking the user to a separate page each time, requiring a reload of the title and nav bar, which almost never change) and I know that if I do so, I will probably break the Forward/Back buttons in the browser. My question I guess is, should I go ahead and AJAX the site, thus requiring the user to use the sites navigation to play the game, or should I leave the site as it currently stands, and use standard hyperlinks and things for navigation?

我想我问的原因是我在网站中构建了一个论坛系统,很多时候我想链接到论坛中的特定主题.

The reason I ask I guess is that I built a forums system into the site, and a lot of times I would want to link say to a particular topic within the forums.

我也愿意接受建议.是否有一种标准(最好没有传统框架)方式来仅重新加载站点的主体区域,同时仍更改 URL 以便用户可以添加书签和前进/后退等?这也可能解决我的问题.我只是在这里寻求最佳解决方案,而不是特定问题的答案.^_^

I'm also open to suggestions. Is there a standard (preferably without traditional frames) way to make only the body area of the site reload, while still changing the URL so that users can bookmark and forward/back, etc? That could potentially solve my problem as well. I'm just asking for the best solution here, not an answer to a specific question. ^_^

谢谢

推荐答案

如果您要启用 AJAX,请不要以牺牲网站上每个重要页面的可访问 URL 为代价.这是人们可以使用的可导航网站的支柱.

If you're going to enable AJAX, don't do it at the expense of having accessible URLs to every significant page on your site. This is the backbone of a navigable site that people can use.

当您将所有功能集中到 AJAX 调用和回调中时,您基本上是在迫使您的用户使用单一路径来访问他们想要的功能和内容——这完全违背了 Web 的功能.人们依赖地址栏和返回按钮.如果您覆盖所有链接,从而使您的站点本质上是一个仅通过 AJAX 更新的页面,那么您将限制用户浏览您的站点并找到他们需要的内容的能力.它还会阻止您的用户分享他们发现的内容(这是重点的一部分,对吧?).

When you shovel all your functionality into AJAX calls and callbacks, you're basically forcing your users into a single path to access the features and content that they want -- which is totally against how the web is meant to function. People rely on the address bar and the back button. If you override all your links so that your site is essentially a single page that only updates through AJAX, you're limiting your users' ability to navigate your site and find what they need. It also stops your users from being able to share what they find (which, that's part of the point, right?).

想想用户对您网站的心理地图.如果他们知道他们是通过主页进入的,那么他们就会去搜索一些东西,然后他们会登陆一个游戏页面,然后他们开始玩一个特定的游戏,这是用户采取的四个不同的动作单元.他们可能在这些页面中的每一个上都做了一些其他更小、更无关紧要的操作——但这​​些是主要单元.当他们单击返回"按钮时,他们应该期望通过他们进入的路径返回.如果您通过 AJAX 调用加载所有这些页面,那么您提供的网站的功能与用户的期望相反.

Think about a user's mental map of your site. If they know they came in through the home page, then they went to search for something, then they landed on a games page, then they started playing a particular game, that's four distinct units of action that the user took. They might have done a few other smaller, more insignificant actions on each of these pages -- but these are the main units. When they click the Back button, they should expect to go back through the path they came in on. If you are loading all these pages through AJAX calls, you're providing a site whose functionality runs contrary to what the user expects.

将您的网站分解为每个重要功能(即搜索、主页、个人资料、游戏——这将取决于您网站的全部内容).在您链接到这些页面的任何地方,都可以通过常规链接和静态 URL 进行链接.

Break your site out into every significant function (ie, search, home, profiles, games -- it'll be dictated by what your site is all about). Anywhere you link to these pages, do it through a regular link and a static URL.

AJAX 很好.但它的艺术在于知道何时使用它,何时不使用它.如果你坚持我上面勾勒的模型,你的用户会很感激的.

AJAX is fine. But the art of it is knowing when to use it and when not to. If you keep to the model I've sketched out above, your users will appreciate it.

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

08-12 09:44