First, the judge is the mobile phone or the Computer browser
Public Static BooleanCheckagentismobile (String UA) {BooleanFlag =false; if(!ua.contains ("Windows NT") | | (Ua.contains ("Windows NT") && ua.contains ("compatible; MSIE 9.0; "))) { //exclude Apple Desktop system if(!ua.contains ("Windows NT") &&!ua.contains ("Macintosh")) { for(String item:CommonConstants.agent) {if(Ua.contains (item)) {Flag=true; Break; } } } } returnFlag; }
UA is: String ua = Request.getheader ("user-agent"); Gets the value in the response header returned by the browser.
Second, to determine whether the browser
The browser will filter out some links to make it inaccessible, such as a shared link, so it will be judged, let the user copy the link or open in the browser
1. Java Judgment:
String ua = ((httpservletrequest) request). GetHeader ("User-agent") . toLowerCase (); if (Ua.indexof ("Micromessenger") > 0) {// is browser }else{
}
2. JavaScript judgment:
function isweixin () { var ua = navigator.userAgent.toLowerCase (); if (Ua.match (/micromessenger/i) = = "Micromessenger") {returntrue; } return false ;}
Or:
function is_weixin () { iffalse ) { returntrue; } return false ;}
java-about the browser