不管是IE还是火狐浏览器,对于iframe 都是有缓存的,可能很多开发的朋友都没有注意,
包子在开发安徽商之都百万网友秒杀盛宴活动
秒杀专题的时候就遇到类似的状况,即使你的iframe地址是php动态页面也都会出现浏览器缓存,
一开始,我以为只要在php的页面使用header禁止缓存就OK了,但是貌似不行。。额。。
我们先来看下,火狐下解决Iframe框架的页面缓存的方法,
从国外的一个博客上看到的一个方法,原文如下:
Hi
I have a page that contains an iframe. The contents of the iframe are created dynamically,
so every time I come to the page containing this iframe I want to force the iframe to refresh. I added these meta tags to the iframe’s 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"
>
and I also add a different random number to the iframe src each time:
<
IFRAME
SRC
=
"http://lab.wehefei.com/index.php?r=xO9X7hEp2wgW5ZTSB38dCrKQnkyq4MA_"
WIDTH
=
900
HEIGHT
=
600
>
It works in Firefox, but in IE6 it still caches the old page.
http://lab.wehefei.com
额。意思你明白不???嘿嘿,还好,我的计算机英语非常过关,哈哈。,。,。。我不就翻译了。,
很简单的,火狐 中 Iframe框架的页面缓存的方法方法两个:
1、使用上面的meta头信息,当然如果使用php动态页面,你最好也发送header头信息,禁止下缓存
2、添加一个随机数。在html的后面。呵呵
下面。我们来看下,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
>