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