`
sundryl6i
  • 浏览: 65244 次
  • 性别: Icon_minigender_1
  • 来自: 湖南
社区版块
存档分类
最新评论

如何解决 IE & FF 中 Iframe 框架的缓存问题

    博客分类:
  • JS
阅读更多

我有一个主页面包含iframe框架,iframe加载一个ajax操作json的页面。当第一次打开这个主页面的时候,iframe中页面读取json数据是最新的,当数据库中修改了数据再刷新主页面的时候,iframe中页面的数据没有从数据库中取得最新的数据。这类问题,在FF中的解决方法可以参考How to get iframe not to cache in IE这篇文章,即在页面的head部分加上以下语句:

<META http-equiv="Expires" content="Mon, 26 Jul 1997 05:00:00 GMT">
<META http-equiv="Last-Modified" content="Sat, 10 Nov 1997 09:08:07 GMT">
<META http-equiv="Cache-Control" content="no-store, no-cache, must-revalidate">
<META http-equiv="Pragma" content="no-cache">

但在IE中无效。IE中解决iFrame缓存问题的方法有两种:

(1) 每次主页面刷新时随机更换iframe的name;

(2) 每次主页面刷新时在iframe的src路径页面赋予一个随机get参数,例如:

<iframe src="http://www.example.com/thepage.html" name="aframe"></iframe>
<script type="text/javascript">
    document.frames['aframe'].location.href += (document.frames['aframe'].location.href.indexOf("?") != -1 ? "?" : "&") + (new Date()).getTime();
</script>

 

来源:http://www.10is.cn/rewrite.php/read-10.html

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics