/*!
* UA Detection and jump
*/
;(function () {
var whatdevice = {};
var Myua = Window.navigator.userAgent.toLowerCase ();
The regular is Lowercase.
/*
* Whether to move Device: returns a Boolean.
*/
Whatdevice.ismobile =/(?: Micromessenger|mobile|iphone|ipod|android|coolpad|mmp|smartphone|midp|wap|xoom|symbian |j2me|blackberry|windows Phone|win ce)/.test (myua);
/*
* Jump to mobile website: parameter 1 is the URL of the mobile Website.
* How to use: whatdevice.go2mob (' Mobile website URL ') If you do not want to jump, the URL of the current access pass parameter itsme=1, such as Www.scshanghjie.com/?itsme=1
*/
Whatdevice.go2mob = function () {
var moburl = arguments[0];//parameter 1
var myarg = [];
Myarg = Window.location.searc H.substr (1). match (/(^|&) itsme= ([^&]*) (&|$)/i); Get URL parameter itsme
var itsme = (myarg! = null && myarg[2]! = null)? myarg[2]:0;
If (itsme! = 1 && moburl ! = null && whatdevice.ismobile) {
window.location.href = moburl;
}
};
/*
* Jump to the computer website: parameter 1 is the website URL of the Computer.
* How to use: whatdevice.go2web (' computer website URL ') If you do not want to jump, the URL of the current access pass parameter itsme=1, such as Wap.scshangjie.com/?itsme=1
*/
Whatdevice.go2web = function () {
var webUrl = arguments[0]; Parameter 1
var myarg = [];
Myarg = window.location.search.substr (1). match (/(^|&) itsme= ([^&]*) (&|$)/i); Get URL parameter itsme
var itsme = (myarg! = null && myarg[2]! = null)? myarg[2]:0;
If (itsme! = 1 && webUrl! = null &&!whatdevice.ismobile) {
Window.location.href = webUrl;
}
};
/*
* Whether the Apple Phone: returns a Boolean.
*/
Whatdevice.isios =/(?: iphone)/.test (myua);
/*
* Whether Android Phone: returns a Boolean.
*/
Whatdevice.isandroid =/(?: android)/.test (myua);
/*
* Whether Browser: returns Boolean.
*/
Whatdevice.iswechat =/(?: micromessenger)/.test (myua);
/*
* Whether Applet: returns a Boolean.
*/
Whatdevice.isminiprogram = Window.__wxjs_environment = = = ' Miniprogram ';
/* Register Global Variables */
Window.whatdevice = whatdevice;
})();
Website Visitor ua Detection and jump