添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

我做magento支付插件的时候 遇到一个 Iframe框架的页面缓存 的问题找了半天终于找到决绝办法
浏览器为了加载速度会缓存iframe 里面的内容,而好多客户是根本不懂强制刷新的,那么我们就需要做一些操作不让缓存,我们一般会选择后面加上随机数的方法来做。
下面是网上普遍说的方法:
原文是这么说的:
不管是IE还是火狐浏览器,对于iframe 都是有缓存的,可能很多开发的朋友都没有注意,
即使使你的iframe地址是php动态页面也都会出现浏览器缓存,

一开始,我以为只要在php的页面使用header禁止缓存就OK了,但是貌似不行。。额。。

我们先来看下,火狐下解决Iframe框架的页面缓存的方法,

从国外的一个博客上看到的一个方法,原文如下:

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.weicot.com/index.php?r=xO9X7hEp2wgW5ZTSB38dCrKQnkyq4MA_" WIDTH=900 HEIGHT=600>

It works in Firefox, but in IE6 it still caches the old page.

http://lab.weicot.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>

但是呢,我觉得他这种方法过于麻烦,需要区分IE和谷歌然后分别来写相应的实现方式。
下面来说一种不需要区分就能没有缓存的方法:

<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>

转载请注明: (●--●) Hello.My Weicot » 兼容解决 火狐、谷歌 包括IE 、浏览器中 Iframe框架的页面缓存的方法

与本文相关的文章

  • WeiCot Framework 快速开发教程 -框架的目录结构说明
  • 在CentOS 7和RHEL 7服务器上升级或新安装PHP 7.4、7.3、7.2、7.1
  • Windows环境搭建 nodejs 开发环境 以及安装 vue 等
  • Coronavirus (COVID-19):How to Protect Yourself & Others
  • 一个简单的Swoole IM 示例 支持离线 断线从连 已读未读
  • php 解析非标准Json(单引号)格式数据处理办法
  • php 协程 yield 一些备注
  • php并发执行问题- 进程锁 用来解决在并发时候的锁控制
  • Swoole 多进程 以及进程通信示例
  • 理解CSS3 transform中的Matrix(矩阵)
  • [算法] 动态规划的问题集锦与讲解
  • php 匿名函数[function() use(){}] 的应用场景 函数注入 并使组件重用
  • 各位觉得文章有帮助的话 记得打赏哦

    magento 1x (73) linux (49) Mysql (32) php (28) 前端 (19) zencart (16) centos 下实现回收站功能 (10) magento (9) magento2 (8) magento2 安装 (8) Composer (7) js (7) NGINX (7) Apache (6) 插件 (6) 负载 (6) linux脚本 (5) magento 插件 (5) 缓存加速 (4) 安全 (4) 运维 (4) Android (4) golang (4) Magento 2 开发 (3) Magento 2 主题 (3) WIN (3) YII (3) mssql (3) shell (3) 模板 (2) XAMPP (2) seo (2) 总结 (2) 电影 (2) TCP/IP (2) magento基础 (2) magento倒计时 (2) magento 特价产品 (2) magento 2x (2) JSON (2) 算法 (2) 多店铺 (2) mysql5.6 (2) JAVA (2) wordpress (2) 优化 (2) Swoole (2) 常见问题解决 (1) GitHub (1) Python (1) 基础知识 (1) 暴力破解 (1) magento 重写购物车 (1) ps (1) magento随机显示产品 (1) 当前分类随机显示产品 (1) Mgaento 支付模块 (1) 支付模块开发 (1) Magento 获取支付信息 (1) 外挂支付模块 (1) zencart模板制作 (1) magento索引 (1) 前端,iframe缓存 (1) magento定向到手机模板 (1) magento自定义调用目录 (1) js加载 (1) ps批处理 (1) js浮动banner (1) Magento2 下载 (1) magento 2 命令 (1) magento2 命令行刷索引 (1) 接口 (1) Usps快递接口文档 (1) USPS DHL快递查询接口 (1) Ebay API (1) 简单对象访问协议 SOAP (1) 表征性状态传输REST (1) 组合产品 (1) 分组产品 (1) 相关产品 (1) magento2 安装不完全 (1) php 设置超时 (1) Magento Image file was not found (1) magento URL (1) MYSQL 远程 (1) Nginx all (1) Magnto 属性 (1) Magento属性筛选 (1) Magento 2 翻译 (1) php 解密加密 (1) 网站技术架构 (1) 数据库读写分离 (1) 邮件服务器 (1) Firewalle (1) Iptables (1) sendmail (1) LNMP (1) 安卓 (1) 自动抢红包 (1) Lock wait timeout (1) magento 1.9x模板 (1) 缓存 (1) centos 安装桌面环境 (1) magento 主题 (1) 运维工具 (1) xsd (1) Magento语言包 (1) LAMP (1) 客服系统 (1) Android Develop (1) php storm (1) Magento 价格规则 (1) 银联接口 (1) 团队搭建 (1) codeigniter (1) 快速开发 (1) redis (1) magento 2 paypal (1) paypal (1) 集群 (1) 脚本 (1) 采集 (1) 经验 (1) 系统 (1) MongDB (1) 系统安装 (1) 多进程 (1) Markdown (1) Tcp (1) go (1) GPU (1) 服务 (1) 易定制 (1) DBA (1) lot (1) COVID-19 (1) nodejs (1) c (1) WeiCot Framework (1)

    2023年七月