PHP标题(“刷新”)问题 [英] PHP header("Refresh") problems

查看:104
本文介绍了PHP标题(“刷新”)问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些代码:

I have some code like:

header('Refresh: 15; url=' . $url);

这很好,除非人们通过Twitter(从Hootesuite客户端发布)访问此网址。显然,在所有浏览器其他比IE这个正常工作。使用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(我们的网站)。所以我在页面上添加了一些鲜为人知的代码,并且如果浏览器是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标题(“刷新”)问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆