Differences in Internet Explorer and Firefox when dynamically loading content, and then back and forth

I am developing a web application where, due to slow access to the database, not all content on the page is loaded immediately, but rather dynamically, when the user clicks the button after an optional selection.

It works great. However, after dynamically loading the content, if I go to another web page and then go back, in Internet Explorer the downloaded content will disappear, i.e. The page will revert to the originally loaded page. However, in Firefox (and Opera), the downloaded content will still be present, i.e. The page will look as if it was before I moved from it.

Firefox behavior is the desired behavior in my case, as the user will regularly navigate through the subpages and return to the main page. So my question is, is there a way to get Internet Explorer to display this behavior or any possible workarounds to get the desired result?

+6
source share
3 answers

Here is my solution for IE. It uses the fact that even if the DOM is reset when navigating back to the page, the values ​​of the input fields are saved.

For each dynamically loaded element, I also have a hidden input field in which I "cache" the loaded value. Then I have a transferFromCache () function that copies the values ​​from each hidden input field to the corresponding element. This function is triggered when the page starts up - which, in the case of IE, is on page load and every time you go to the page.

This method could probably be used to store javascript variable values.

+3
source

I don't think there is a way to get IE to emulate FF in this way. The reason is that this concerns the fundamental aspects of browsers. FF uses a mechanism for this page history called "Fast DOM Caching", which (from my limited understanding) basically means that when it puts the page in the browser history, then it will store the current DOM (so the current state of the page) in serialized format, which means that when the page reloads from history, the state is saved, and FF can do it much faster, since most of the work has already been done (parsing HTML in the DOM, etc.). For comparison, IE will simply save the HTML that was originally received as a history file and reload it when navigating through the history.

+2
source

Here's an article on persisting state in session variables that might help

+2
source

All Articles