This code is used to solve the problem of displaying the Header in the mobile browser, because the browser's title has already been displayed. If the PC browser does not display the Header, it will feel something is missing, because the title of the PC browser is not clear and the Header is not displayed as beautiful. The code is very simple, so
This code is used to solve the problem of displaying the Header in the mobile browser, because the browser's title has already been displayed. If the PC browser does not display the Header, it will feel something is missing, because the title of the PC browser is not clear and the Header is not displayed as beautiful.
The code is very simple, so I will not explain it in detail. If you have any questions, I would like to add it. You are welcome to ask questions!
Asp.net code
static public List
MobileNames = new List
{ iphone, android, mobile, ucweb, opera mini, samsung, htc, lg, sonyericsson, nokia, mot, blackberry, j2me }; protected void Page_Load(object sender, EventArgs e) { String clientType = HttpContext.Current.Request.UserAgent.ToLower(); Boolean isPCBrowser = true; foreach (String mobile in MobileNames) { if (clientType.Contains(mobile)) { isPCBrowser = false; break; } } pnlHeader.Visible = isPCBrowser; }
Because the browser can set Request. UserAgent at will, there is no absolutely correct calculation method to determine whether the browser is a mobile phone or a PC. This makes it easier to test 95% correctly on multiple browsers.