If IE 6 , I want to produce warning and free download other browser icons

半城伤御伤魂 提交于 2019-12-05 22:17:01

问题


My web site want to be open IE7 and above .If IE 6 ,I want to produce warning and free download other browser icons .Is it possible?


回答1:


You can get some examples that don't require server side scripting from ie6nomore.com.

They use the conditional comments feature of IE, like this:

<!--[if lt IE 7]>
Your browser is outdated!
<![endif]-->

But the examples on the site actually offer links to other browsers. Of course, you can roll your own version that suits your layout better.

Of course, you can do this server side if you prefer, since you're using PHP anyway. The other examples here using $_SERVER["HTTP_USER_AGENT"] should get you started. Using get_browser may be overkill, as it requires a fairly large data file to function.

If you're only interested in detecting old IE versions server side, this should do:

preg_match('/; MSIE (\d+.\d+)/', $_SERVER['HTTP_USER_AGENT'], $matches);

if (count($matches) > 1 && $matches[1] <= 6.0)
{
    echo "Your browser is outdated";
}



回答2:


Use IE conditional comments in your page

<!--[if lt IE 7]>
include a warning here (in an iframe, perhaps, to save extra bandwidth)
<![endif]-->



回答3:


There exits a simple jQuery plugin for this it's called IE Alert. Check it out on: http://nmsdvid.com/iealert/




回答4:


You can check the $_SERVER['HTTP_USER_AGENT'] variable for IE.

if (eregi("MSIE", $_SERVER["HTTP_USER_AGENT"]) ||
   eregi("Internet Explorer", $_SERVER["HTTP_USER_AGENT"])) {
   // IE
}



回答5:


You should be able to do so easily by using the built-in get_browser function.

In case you wish to see what the output looks like if visited by IE 6, you can grab a user agent string from UserAgentString.com to test it out.




回答6:


Alternatively you could also check it with a JavaScript

/*
*   Check whether the current browser is IE6
*/
function isBrowserIE6() {
    if (Sys.Browser.agent == Sys.Browser.InternetExplorer && Sys.Browser.version < 7) {
        return true;
    } else {
        return false;
    }
}

(The above would just work in a ASP.net environment. Here's a blog post which handles IE browser checking the native way).

You then add an HTML container element on your page

<div id="ie6BrowserWarning" style="display:none">
   Your browser is outdated. Please download one of the alternative browsers!
   <!-- Set of links to Firefox, Chrome, Safari, Opera,... -->
</div>

And on page load you do

<html>
<head>
<script type="text/javascript">

  function doIE6WarningCheck()
  {
     var element = document.getElementById("ie6BrowserWarning");
     var isIE6 = isBrowserIE6();
     if(element != null && isIE6 == true)
     {
        element.style.display = "block";
     }
  }
</script>
</head>
<body onLoad="doIE6WarningCheck()">
   <div id="ie6BrowserWarning" style="display:none">
      Your browser is outdated. Please download one of the alternative browsers!
      <!-- Set of links to Firefox, Chrome, Safari, Opera,... -->
   </div>
</body>
</html>

I didn't check that, just wrote it out of my head right now. You'd have to do that, but I guess it should work. Firebug is always a good option for JavaScript debugging.




回答7:


use their script to promote user to upgrade their browser its customizable.you can check any browser not only ie 6

http://www.browser-update.org/

How can I show a message to IE6/IE7 browsers to upgrade to IE8 and have IE8 not show the IE7 warning?



来源:https://stackoverflow.com/questions/1283704/if-ie-6-i-want-to-produce-warning-and-free-download-other-browser-icons

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!