How to use JS and JAVA to determine if it is a WeChat browser

Source: Internet
Author: User
Code snippets, code sharing, PHP code sharing, Java code sharing, Ruby code sharing, Python code sharing, HTML code sharing, CSS code sharing, SQL code sharing, to share JavaScript code, you must require the mobile web page to run in the browser. The first thought is to add JavaScript code on the page to verify whether the browser is used.

The code is as follows:

/* Determine whether the browser */function isweixin () {var ua = navigator. userAgent. toLowerCase (); if (ua. match (/MicroMessenger/I) = "micromessenger") {return true;} else {return false ;}} is unwilling to modify because there are many pages. So I plan to use the JAVA filter to find information .. getHeader ("user-agent") can obtain the String ua = (HttpServletRequest) request of the browser ). getHeader ("user-agent "). toLowerCase (); if (ua. indexOf ("micromessenger")> 0) {// browser validation = true ;}

The above is to teach you how to use JS and JAVA to determine whether it is the details of a browser. For more information, see other related articles on php Chinese network!

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.