识别微信内置浏览器

JS版本:

function isMicroMessenger() {
    var result = false;
    var userAgent = window.navigator.userAgent;    
    if(userAgent.indexOf('MicroMessenger') > -1) {
        result = true;
    }
    return result;
}

JAVA版本:

public static boolean isMicroMessenger(HttpServletRequest request) {
    boolean result = false;
    // 获取浏览器的User-Agent
    String userAgent = request.getHeader("User-Agent");
    // 判断是否为微信内置浏览器
    if(null != userAgent && userAgent.contains("MicroMessenger")) {
        result = true;
    }
    return result;
}


你可能感兴趣的:(微信开发)