开发者

Prevent IE6 visitors

开发者 https://www.devze.com 2023-03-03 23:42 出处:网络
How can I drop the using of IE6 to browse my websi开发者_高级运维te ? Something like : if ie6 => die

How can I drop the using of IE6 to browse my websi开发者_高级运维te ?

Something like :

if ie6 => die

I am using ASP.Net

Thanks


In asp.net you can look at the Request.Browser in Session_start and do what you want from there. Perhaps Response.Redirect("www.getfirefox.com")

protected void Session_Start(Object sender, EventArgs e) {
    var browser = Request.Browser;
    if (browser.browser == "Whatever IE is" 
        && browser.version == "your least fave version" )
        Response.Redirect("www.getfirefox.com");
}

See msdn for the httpbrowsercapabilities class

You may want to show a banner on your website. Microsoft are running a campaign to get people off IE. Check out http://www.theie6countdown.com/ the banner is on http://www.theie6countdown.com/join-us.aspx

As others will no doubt answer there are many ways to detect browser version.

Conditional css comments

<!--[if IE 6]>

and Javascript

alert( BrowserDetect.browser + ' ' + BrowserDetect.version); 

are 2 other ways.


If you want, this can be done also with conditional comments:

<!--[if lt IE 7]>
<script type="text/javascript">
    window.location = "someplace.html";

    // Or maybe suggest other things, i.e. a browser upgrade, installing Chrome Frame etc.
</script>
<![endif]-->


You can look at the user agent header and if it is IE 6 redirect to a specific page.

Here is a handy list of IE user agent strings, grouped by version.

0

精彩评论

暂无评论...
验证码 换一张
取 消