View
 

History

Page history last edited by Benjamin Lupton 11 months, 4 weeks ago Saved with comment

 

type: utility

release: 0.0

priority: very low

status: in planning

documentation: N/A

demo: N/A

 

 


 

1 - Description:

 

Utility for managing browser history. Should use HTML5 history API (pushState) and fall back to changing location.hash with custom hashchange events where necessary.

 

Some references:

 

 

To test for HTML5 history support, the most common test, e.g. used by Modernizr, is !!history.pushState. That is a start, but doesn't help when the implementation is as broken as it seems to be in Mobile Safari/iOS 4.2.x. A potential test, used in jQuery Mobile to detect hash change support, would try to push state once, save the location.pathname, push again, then check if there is a difference. If so, support is there, go back twice to clean up. It breaks forward history, but only once if the test result is stored and reused.

Too bad that that doesn't work for Mobile Safari, which updates location.pathname, but not the actual URL displayed in the browser (which gets loaded on reload). Could be related to this WebKit bug.

Mobile Safari also doesn't update the back/forward buttons properly. When the back button works after using pushState (not very reliable), a tap on back doesn't enable the forward button.

Checking for history.length, then using pushState, then checking history.length again and comparing the result could be a way to check if history.pushState is actually supported. But it looks like doing that check on pageload provides no useful result, as even if Chrome, with a proper pushState implementation present, the history.length doesn't change. Delaying the check produces different lengths, even on iOS 4.2.x.

While the native browser buttons are unreliable and either don't work at all or don't update the address bar, history.back() and history.forward() work fine, trigger the right popstate event and update the address bar to the correct value.

 

Note on the second argument to history.pushState, title: Both WebKit and Mozilla ignore the argument and do nothing with it. See Mozilla bug and WebKit bug.


 

2 - Visual Design:

 

No visuals necessary.

 


 

 

3 - Functional Specifications/Requirements:

 

(Detailed description of how the script will be structured: defaults, options, architecture, extensibility, etc.)

 


 

4 - Markup & Style:

 

No markup necessary. 

 

5 - Latest version of plugin:

 

(Link to the latest version in the jQuery UI trunk here)

 


 

6 - Open issues being discussed

 

(Use this area to place things that we're hashing out like features and options we're not sure we should include, questions about how this fits into UI and relates to other widgets and utilities, known problems, whether features should be broken across multiple releases, etc.)

 


 

 

 

 

Comments (8)

Mikage Sawatari said

at 10:21 am on Jun 24, 2009

I am an author of jquery history plugin.
http://www.mikage.to/jquery/jquery_history.html

I got the request that want to include this plug-in in jquery ui.

Can my jquery history plug-in be included in jquery UI?

Ca-Phun Ung said

at 10:48 am on Jun 24, 2009

Hey, I used your history plugin before and I think it is one of the best out of the few I came across. Not sure what others think but I'd love to see it included.

Yanick said

at 10:52 am on Jun 24, 2009

I believe that, as localization, history should be a feature to have with widget, especially when such have states (ie: tabs, accordeon, layout states, etc.) But I do not think that this is a high priority matter. I, for one, don't have much use of it for now, but UI integration with it would be nice.

Jaggi said

at 10:28 am on Sep 2, 2009

This plugin really does need to be completed and implemented into some cases of jqueryUI, especially stuff like the tabs plugin. It really is a very big issue on the whole accessibility side of things and jquery likes to boast support for this they need to get on this one.

@mikage - i've used your plugin before and liked it but you website is horribly lacking. If you ever wish to be considered by the jquery i would suggest moving your plugin into the jquery plugins area and providing some proper documentation. Also your site is really confusing on which browsers you actually support, i know it works in ff 3.5 but you list ff4.0 and not any other versions, the same is true for your IE support.

Veselin Hadjiev said

at 7:48 am on Mar 26, 2010

@mikage - your plugin doesn't work if manually change the url (ie7/8), which I think is very important. I found this solution that works very well in all browsers - http://www.asual.com/jquery/address/

Benjamin Lupton said

at 10:28 am on Feb 9, 2011

-1. jQuery Address doesn't support the HTML5 History API's data, titles and replaceState functionality, it also uses a non-standard API. Would not be a good fit for this.

fnagel said

at 12:42 pm on Jun 7, 2010

+1. Mikages plugin seems to have problems with manually changes of url and does not support title changing.
Ive tested a few history plugins and i liked jQuery Addresss. It works fine corss brower and is well documented.

I decided to add asuals plugin to to my jQuery UI ARIA widgets (lightbox, UI Tabs addon, sortable tables). Please see link below for further information.
http://www.felixnagel.com/blog/artikel/2010/06/06/jquery-aria-with-browser-history-support-tabs-lightbox-and-sortable-tables/

Benjamin Lupton said

at 10:32 am on Feb 9, 2011

History.js - https://github.com/balupton/History.js - follows the HTML5 History API providing graceful degradation for HTML4 browsers including support for data, titles and replaceState. As it follows the original API very closely, continues to have support for all the API's features, degrades and upgrades gracefully, and supports multiple javascript frameworks it seems as a very good fit. It would also provide drop-in/plug-and-play support for jQuery Mobile without any extra work another plus.

As the author of History.js I can guarantee that it is actively developed, maintained and supported.

PS. Posted this on the GitHub Issue Tracker as well https://github.com/jquery/jquery-mobile/issues/labels/Ajax%20Nav#issue/16/comment/738148

You don't have permission to comment on this page.