最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Ajax Requests Saved on Browser's History - Stack Overflow

programmeradmin4浏览0评论

Is there an easy way to save ajax requests into a browser's history so that when you use the back button it will preserve the last state of the DOM?

Websites like twitter and digg that use an ajax pager have a usability flaw where if you click next page several times then click away from the site and then return using the back button, you lose your place in the viewport since the DOM is restored to the first initial request.

I noticed safari actually preserves the dom after a few ajax requests on some sites.
Here is an example, Goto , Click next a few times then click on an image and then click your back button. On webkit it preserved the last DOM state, but on gecko and ie it does not.

What would be the easiest way to replicate this functionality on other browsers?

Is there an easy way to save ajax requests into a browser's history so that when you use the back button it will preserve the last state of the DOM?

Websites like twitter and digg that use an ajax pager have a usability flaw where if you click next page several times then click away from the site and then return using the back button, you lose your place in the viewport since the DOM is restored to the first initial request.

I noticed safari actually preserves the dom after a few ajax requests on some sites.
Here is an example, Goto http://13gb., Click next a few times then click on an image and then click your back button. On webkit it preserved the last DOM state, but on gecko and ie it does not.

What would be the easiest way to replicate this functionality on other browsers?

Share Improve this question edited Oct 20, 2010 at 5:40 David asked Oct 18, 2010 at 19:32 DavidDavid 9,9995 gold badges30 silver badges32 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 3

I'm not the first person to tackle this type of problem. I've drawn inspiration and know-how from several places to get this up and running:

The original bookmark/back button fix, as used by Flash developers for a little while now:

http://robertpenner./experiments/backbutton/flashpage.html

I've not actually looked at how they implemented their solution but this is where I got the idea for replacing Robert Penner's frames with iframes:

http://dojotoolkit/intro_to_dojo_io.html#so-about-that-thorny-back-button

Rich Rutter's use of the hash for bookmarking:

http://clagnut./sandbox/slideshow.html#5

For this little experiment I've used Harry Fuecks' JPSpan

It's a fantastic framework that makes the methods you define in your server-side PHP classes available to your Javascript via XmlHttpRequest.

It's the simplest way I've e across to get started with AJAX. I had the guts of my demo up and running in about 10 minutes! I'm using Algorithm's Timer object:

http://codingforums./archive/index.php/t-10531.html

And Scott Andrew's cross-browser event handler: http://scottandrew./weblog/articles/cbs-events

Source: http://www.contentwithstyle.co.uk/content/fixing-the-back-button-and-enabling-bookmarking-for-ajax-apps

For jQuery: https://stackoverflow./questions/116446/what-is-the-best-back-button-jquery-plugin

You may be interested in the jQuery History plugin: http://tkyk.github./jquery-history-plugin/

发布评论

评论列表(0)

  1. 暂无评论