A problem related to the issue tackled in the previous phrase is the back button (and, of course, the forward button as well). When the page's URL does not change but its contents do, the back button does not really work as expected. To solve this problemand again this phrase can show only a generic approach, not a full solution, since there are so many implementation-dependent detailstwo subproblems have to be worked on:
The solution to the second subproblem is to use a hidden iframe that will load an invisible page, just to get an entry in the history of the page. Here is the iframe: <iframe src="/books/3/490/1/html/2/loader.html" name="loader" style="display:none"></iframe> Whenever something happens on the page (AJAX-wise), the loader frame must be forced to load again, with data appended to the URL (unlike the previous code, this time there must be a reload): if (window.ActiveXObject) { window.frames["loader"].window.location.search = "?" + escape(data); } Finally, the loader frame must take care of applying any loaded data to the main document; at least for Internet Explorer this is required, since in this browser the back and forward buttons change the contents of the iframe! window.onload = function() { if (location.search.length >= 2) { var data = unescape( location.search.substring(1)); top.applyData(data); } }; This makes the coder's life much more complicated, especially if there are many different AJAX effects on the page. But just to repeat one of the final sentences from the previous phrase: Your users benefit greatly from this convenient feature. And again, this workaround does not work with Safari and Konqueror (yet).
|