C # perform different processing methods based on the client browser

Source: Internet
Author: User
Yesterday, I was prompted to upgrade IE to 360, So I upgraded the browser following the Upgrade Wizard.

However, in the Customer Information Management System (CRM) with the B/S structure originally designed, the Javascript statement originally executed on the login page was scaled down to the upper left corner of the screen under ie8.

I have always sought perfection for the program. Find a solution.

After re-designing JS statements, I thought it would solve the problem if I could correctly open the browser in my browser environment (IE8. Haha ~~

I tested it in my colleague's Computer Browser (IE6). As a result, this JS statement can only be run in IE8. IE6 also moves the browser to the upper left corner of the screen.

The solution is to execute different JavaScript codes based on the browser type of the client.

 

CS code:

 

Public class javascriptoperation {# region browser control // the browser is opened with the same screen size. // IE6 supports public static string winopenmax = "<body onload = moveTo (); resizeTo (screen. width, screen. height-30);> "; // the browser and screen size are the same. // IE8 supports public static string browsersizemax =" <script language = JavaScript> "+" window. moveTo (0, 0); "+" window. resizeTo (window. screen. width, window. screen. height-30); "+" window. focus (); "+" </SCRIPT> "; # endregion ////////////////////////////////////// /// // according to the client different types of browsers, process different httpbrowsercapabilities BC = request. browser; string bctype = BC. type; this. response. write (bctype); Switch (bctype) {Case "IE6": This. response. write (javascriptoperation. winopenmax); break; Case "IE8": This. response. write (javascriptoperation. browsersizemax); break; default: This. response. write (javascriptoperation. winopenmax); break ;}

Author: Duan Liqing QQ: 14035344

Card Water and Electricity Thermal System

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.