PHP header(quot;Refreshquot;) problems(PHP 标头(“刷新)问题)
问题描述
我有一些类似的代码:
header('Refresh: 15; url=' . $url);
这很好用,除非人们通过 Twitter 访问此 URL(从 Hootesuite 客户端发布).显然,在 IE 以外的所有浏览器 other 中都可以正常工作.使用 IE,从 Hootesuite 链接,这不能正确刷新;直接链接就可以了.
This works fine, except when people are visiting this url via Twitter (posted from a Hootesuite client). Apparently, in all browsers other than IE this works properly. With IE, from the Hootesuite link, this does not refresh properly; a direct link does.
为什么?
推荐答案
事实证明,因为我们使用的 URL 设置了一个 cookie,而 Hootsuite 创建了一个框架,IE 不会信任第三方 cookie (我们的网站).因此,我在页面中添加了一些 framebuster 代码,并在浏览器是 IE 时触发它立即"发生.代码如下:
It turns out that, because the URL we're using sets a cookie, and Hootsuite creates a frame, that IE won't trust the third party cookie (our site). So I've added some framebuster code to the page, and triggered it to happen "immediately" if the browser is IE. Code is below:
<meta http-equiv="refresh" content="15;url=<?php echo $url ?>" />
<script type="text/javascript">
var timeout = 1;
if (navigator.userAgent.match(/MSIE/)) { timeout = 1; } else { timeout = 14500; }
setTimeout('if (top != self) top.location.replace(self.location.href)', timeout);
</script>
也许有一天这会帮助其他一些随机用户.
Maybe this will help some other random user out there some day.
这篇关于PHP 标头(“刷新")问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:PHP 标头(“刷新")问题


基础教程推荐
- 如何在 PHP 中的请求之间持久化对象 2022-01-01
- Libpuzzle 索引数百万张图片? 2022-01-01
- 在多维数组中查找最大值 2021-01-01
- XAMPP 服务器不加载 CSS 文件 2022-01-01
- mysqli_insert_id 是否有可能在高流量应用程序中返回 2021-01-01
- 在 PHP 中强制下载文件 - 在 Joomla 框架内 2022-01-01
- 在 Woocommerce 中根据运输方式和付款方式添加费用 2021-01-01
- WooCommerce 中选定产品类别的自定义产品价格后缀 2021-01-01
- 超薄框架REST服务两次获得输出 2022-01-01
- 通过 PHP SoapClient 请求发送原始 XML 2021-01-01