Control browser type
In .aspx page, I want to control t开发者_JAVA技巧he browser type and if it is IE 6 , I want to show a message.
How can I do it?
This should be approached by using conditional comments.
<body>
....
<!--[if lte IE 6]>
<div class="bigAndBold">YOUR BROWSER SUCKS</div>
<![endif]-->
....
</body>
How to: Detect Browser Types and Browser Capabilities in ASP.NET Web Pages
I'm not certain on the output for IE6, but you could do something like:
if (browser.Browser == "IE" && browser.Type == "6"){
phMessage.visible = True;
}
<%
var b = Request.UserAgent.ToString();
if (b.Contains("MSIE 6.0"))
{
Response.Write("IE 6!");
}
// Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0) == IE 9
// Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0.2) Gecko/20100101 Firefox/6.0.2 == FF6
%>
精彩评论