IE8 reloads dynamic iframe content from cache to invalid iframe

I have a page with multiple iframes. Each iframe invokes some javascript that dynamically writes new frames to the parent window's document.

This works great when loading the first page. But if the page is refreshed in IE8 (and earlier), one of the dynamically generated iframes will be loaded from the cache into one of the hard-coded slots on the parent page. See the following example:

http://www.risingspiral.com/ie8-iframe-refresh/

When upgrading to IE8 (may take a couple of attempts), Spot 2_ will be loaded from cache into spot3.html iframe. spot3.html will not be called at all.

I am already protected from the iframe IE dynamic update problem described here:

http://buildingonmud.blogspot.com/2010/06/ie-iframe-refresh-and-back-button.html

But the problem still seems. It is also interesting that the problem always arises (at least for me) between iframes spot2.html and spot3.html.

I tried a ton of different configurations to try to get around this problem. So, I am looking for new offers.

Any ideas?

+4
source share
3 answers

I have a very similar problem when a dynamically generated iframe immediately gets stuck in the first src after loading, and even if the parent page changes the iframe src attribute every time it reloads, the iframe still loads the first.

After dealing with this for several hours, I realized that it was just <IE8 update error, and if the page navigates through a link or through a URL to the address bar, everything works as expected. Therefore, unless you refresh the page or refresh it by entering the address again, you should be fine.


Update:

The problem seems to be fixed if you set the SRC iframe attribute again, for example

iframe.src = iframe.src; 

This seems to be IE8 to really respect the given URL.

0
source

An old question, but the problem still exists. I'm watching right now. The problem is that I cannot control when the iframe will be loaded, because it is generated by the script inserted into the page asynchronously.

After some hacks, I decided to update the frames after a timeout. This is the best solution I have found.

 if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){ var ieversion=new Number(RegExp.$1); if (ieversion<=8){ setTimeout(function(){ iframeReload(); }, 1000); function iframeReload() { $("iframe").each(function(index) { $(this)[0].src = $(this)[0].src; }); } } } 
0
source

I had the same problem and fixed it by creating an iframe with a different identifier every time (tested only in IE11, but hopefully this should solve the problem in all versions):

 iframe.id = iframe.name = "iframe$" + Math.floor(Math.random() * new Date().getTime()); 

Please note that setting the name may not have any effect (for verification, I can only say that setting the name only does not solve the problem)

0
source

Source: https://habr.com/ru/post/1387660/


All Articles