Determine if the browser client is a mobile client

Source: Internet
Author: User

1.c#
String Ospat = "mozilla|m3gate|winwap|openwave| Windows nt| Windows 3.1|95| blackcomb|98| me| X window| longhorn|ubuntu| Aix| Linux| amigaos| beos| Hp-ux| openbsd| freebsd| netbsd| os/2| osf1| SUN ";
String uagent = request.servervariables["Http_user_agent"];
Regex reg = new regex (OSPAT);
if (Reg. IsMatch (uagent))
{
Response.Write ("Computer access");
}
Else
{
Response.Write ("Mobile Access");
}
Response.Write ("<br/>" + uagent);


2.javascript

$ (document). Ready (function () {
platforms, devices, and operating systems
var system = {
Win:false,
Mac:false,
Xll:false
};
Testing platform
var p = navigator.platform;
System.win = P.indexof ("win") = = 0;
System.mac = P.indexof ("mac") = = 0;
system.x11 = (P = = "X11″) | | (P.indexof ("Linux") = = 0);
Jump statement
if (System.win | | system.mac | | system.xll) {//Turn to Background landing page
Window.location.href = "http://www.offcn.com/zhuanti/2015gkyh/";
} else {
Window.location.href = "http://m.offcn.com/zhuanti/2015gkyh/";//Mobile phone
}
});

Determine if the browser client is a mobile client

Related Article

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.