当用户使用Internet Explorer时重定向到新页面 [英] Redirecting to a new page when a user is using Internet Explorer

查看:104
本文介绍了当用户使用Internet Explorer时重定向到新页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用下面的代码将使用Internet Explorer的用户重定向到一个新页面,但很明显,代码有问题,因为当我使用Internet Explorer时,该站点不再加载。 / p>

以下是代码:

 <?php $ b $如果(strpos($ _ SERVER ['HTTP_USER_AGENT'],'MSIE')!== FALSE){
$ url = htmlspecialchars($ _ GET ['url']);
header('Location:http://'.$url。');
}
?>

因为我不知道我在做什么错误,如果有人可以发布正确的方式来执行正确的编码。

对于现代的IE,您可以使用:

  if(strpos($ _ SERVER ['HTTP_USER_AGENT'','Trident' )!== false){
header('Location:ie-page.php');
出口;
} else {
printHello World;
}


I am using the code below in order to redirect the users who use Internet Explorer to a new page, but obviously there is something wrong with the code, since the site doesn't load anymore when I am using Internet Explorer.

Here is the code:

<?php
if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== FALSE) {
    $url = htmlspecialchars($_GET['url']);
    header( 'Location: http://'.$url.'' ) ;
    }
    ?>

Since I don't know what I am doing wrong it would be greatly appreciated if someone could post the right way to do it with the right coding.

Thanks in advance.

解决方案

For modern IE you can use:

if (strpos($_SERVER['HTTP_USER_AGENT'], 'Trident') !== false) {
    header('Location: ie-page.php');
    exit;
} else {
    print "Hello World";
}

这篇关于当用户使用Internet Explorer时重定向到新页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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