zoukankan      html  css  js  c++  java
  • 兼容解决 IE 和(火狐)FF中 Iframe框架的页面缓存的方法

    不管是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>

    其实,方法还是有的,包子在开发过程遇到的情况就是,每次秒杀到的商品之后,再点击之后,发觉,php 的统计页面秒杀的到的数量不变,

    额。。iframe框架的缓存我问题。

    包子在其实开发过程中的实际情况是:

    包子的专题里面的链接是静态页面,

    包子的做法是:在这些框架链接地址后面加上时间戳参数。如:&t=1123231212

    然后在加载的php页面,使用header信息,禁止缓存数据,oh my lady gaga ,也OK,哈哈、、

    额。还是那么句话,开发在于实践中总结,还有E文要好,不然看不懂老外的E文,那不就杯具了。唉。、。、

     

    来源:合肥网UED   http://lab.wehefei.com
  • 相关阅读:
    C# 不用添加WebService引用,调用WebService方法
    贪心 & 动态规划
    trie树 讲解 (转载)
    poj 2151 Check the difficulty of problems (检查问题的难度)
    poj 2513 Colored Sticks 彩色棒
    poj1442 Black Box 栈和优先队列
    啦啦啦
    poj 1265 Area(pick定理)
    poj 2418 Hardwood Species (trie树)
    poj 1836 Alignment 排队
  • 原文地址:https://www.cnblogs.com/jincon/p/2027189.html
Copyright © 2011-2022 走看看