views:

73

answers:

3

I'm developing a web application where, due to slow database access, not all content in a page is loaded immediately but rather dynamically when the user clicks a button after optionally making a selection.

This works fine. However, after dynamically loading content, if I navigate to a different web page, then navigate back, in Internet Explorer the loaded content will have disappeared, i.e. the page will have reverted to the originally retrieved page. In Firefox (and Opera as well), however, the loaded content will still be there, i.e. the page will look like it did before I navigated away from it.

The Firefox behaviour is the desired behaviour in my case, as the user would routinely navigate to subpages and go back to the main page. My question is therefore, is there any way I can force Internet Explorer to exhibit this behaviour, or are there any possible workarounds to get the desired result?

+1  A: 

I don't think there's a method to get IE to emulate FF in this manner. The reason is to do with fairly fundamental aspects of the browsers. FF uses a mechanism for it's page history called 'Fast DOM caching' which (from my limited understanding) basically means that when it puts a page into the browser history then it will store the current DOM (so the current page state) in a serialised format, which means that when the page is reloaded from history the state is preserved and FF can do this much quicker as a lot of work is already done (parsing the HTML into a DOM, etc). In comparison, IE will simply store the HTML received initially as it's history file and will reload it when navigating history.

workmad3
It seems that, in regard to IE, this is almost so but not quite. As an example, in my application I use javascript filtering and pagination (of contents in a table). I use "select" input boxes for the filtering. In both IE and FF, the selected options are remembered after navigating away and back again. I use javascript variables for pagination status. This is information is remembered in FF, but reset in IE.
Knut Arne Vedaa
+1  A: 

Here is an article about saving state in session variables, which may help

Robert
Thanks. This article seems to be describing the IE behaviour. In FF, javascript is not reset when navigating away and back. But the workarounds could be useful in IE, I might try the second one (using hidden input fields for storing information).
Knut Arne Vedaa
A: 

Here is my workaround solution for IE. It utilizes the fact that, even if the DOM is reset when navigating away and back to a page, input field values are still remembered.

For every dynamically loaded element, I also have a hidden input field where I "cache" the loaded value. I then have a function transferFromCache() which copies the values from each hidden input field to the corresponding element. This function is run at page init - which, in IE's case, is at page load AND every time one navigates back to the page.

This technique could probably be used to store the values of javascript variables as well.

Knut Arne Vedaa