Jens Franke's excellent session on the Flashforum Tour about Flash usability issues inspired me to give the old "Flash breaks the back button, there is no deep-linking possible and there is no way to bookmark pages" problem another go. To make it short: I wasted a day only to find out in the end that Kevin Newman already seems to have developed a solution that works. But let's start from the beginning.
As you probably know several people have already tackled parts of the problem with success:
- Robert Penner was the first to invent a working back button solution for Internet Explorer
- Chris Hendershot improved Robert's method so it works also with other browsers and especially on Macs
All these methods work with a hidden frame, and do not change the visible URL when navigating. The consequence is that while they enable the back button they do not address the bookmarking problem.
There's an article by Kevin Lynch which demonstrates how to track states within Flash applications by updating the visible URL and title tag of the html page and thus allowing to bookmark sub-pages of Flash sites. Unfortunately this method does not allow to use the back button.
In theory the whole affair could be so easy to solve with the help of named anchors. Named anchors are like markers within a HTML page which allow to jump to certain positions on a page without reloading it, in HTML they look like this: <A name="example">. They are perfectly suited for our purpose because a) they get shown in the URL (http://www.blahblah.com/page.html#example) and b) they register in the browsing history which means you can navigate back and forth and bookmark them.
Macromedia even introduced them in Flash MX. The problem with the way they are implemented is that they are static and do not behave correctly. Static means that you will have to compile them into the swf and cannot generate them dynamically with ActionScript - this makes them pretty useless for sites or applications that get their content or structure from external files, but if you can live with that there is a good tutorial on noscope how to use them.
Unfortunately the internal Flash anchors have an annoying side-effect: when you have for example 4 anchors/pages "one", "two", "three" and "four" and navigate directly from "one" to "four", the browser history will register "one-two-three-four" instead of "one-four", so clicking the back button will take you to "three" in this case.
This is where I started searching Google and I should have done so earlier, because it looks like other people ended up in the same cul-de-sac. But of course you first have to know the problem before you know how to search for it. And whilst searching for a solution for the IE show-stopper I finally stumbled across this:
It looks like Kevin Newman has indeed found a way to make the back & forward buttons work and bookmarking possible in Flash: his FlashSuite is still under development, but at least in all my Windows browsers it really seems to behave as intended. It uses his HistoryKeeper class which might also be interesting for AJAX programmers as they face some of same problems as Flash developers.
The question is now - how compatible is this method? I think Kevin (and everyone who thinks about using it) might be interested in getting some feedback how and if it works in various browser/OS combinations. So if it doesn't work for you - please leave a comment or send him an email which combination you were using.
[UPDATE] As you can read in the comments Leo Bergman has also developed a system that works in most of the browsers (except for the usual ill-behaving culprits Opera, Netscape and Safari). See the demo here. Download the source files here.Posted at October 02, 2005 03:27 PM | Further reading