I';我对这个PHP浏览器特定的警报有问题


I'm having an issue with this PHP browser-specific alert

我目前正在为开发人员编写一个设计教程网站,我有一段代码,如果最终用户在屏幕上使用过时版本的IE,它基本上会在页面上发出一个小警报。

尽管听起来没用,但这正是客户想要的。哦,好吧。

基本上,当你点击"关闭这个盒子"链接时,我无法关闭这个该死的东西。这是代码。有什么建议吗?

<?php
// IE6,7,8 string from user_agent
$ie6 = "MSIE 6.0";
$ie7 = "MSIE 7.0";
$ie8 = "MSIE 8.0";
// detect browser
$browser = $_SERVER['HTTP_USER_AGENT'];
// yank the version from the string
$browser = substr("$browser", 25, 8);
// html for error
$error = "<div class='"error'" id='"error'"><strong>Alert:</strong> It appears that you    
are using Internet Explorer 6, 7, or 8.  While you may still visit this website we 
encourage you to upgrade your web browser so you can enjoy all the rich features this 
website offers as well as other websites. Follow this link to <a 
href='"http://www.microsoft.com/windows/downloads/ie/getitnow.mspx'"><strong>Upgrade 
your Internet Explorer</strong></a><br /><div class='"kickRight'"><a href='"javascript: 
killIt('error');'"> Close This Box</a></div></div>";
// if IE6 set the $alert 
if($browser == $ie6){ $alert = TRUE; }
if($browser == $ie7){ $alert = TRUE; }
if($browser == $ie8){ $alert = TRUE; }
?>

然后你把它添加到你想要的身体中:

<!-- IE6 Detect Advise Notice -->
<?php if($alert){ echo $error; } ?>
<!-- // end IE6 Detect Advise Notice -->

我不能让这该死的结束。我不知道问题出在哪里。可能是javascript试图关闭PHP错误框。我不知道基于c的语言,所以我不知道。如有任何帮助,我们将不胜感激。

您的关闭按钮正试图启动一个名为killIt()、参数为'error'的JavaScript函数。我猜你还没有在页面上包含该函数,或者其中有错误。

只需将killIt javascript函数添加到HTML中。它不会删除服务器端的任何PHP代码,而是删除浏览器中PHP代码的HTML输出。您还没有向我们展示killIt的代码,但我猜它要么隐藏要么删除PHP打印的DIV。