Instance methods that restrict Web pages to be opened only in WeChat built-in browsers

Source: Internet
Author: User

About the two scope of the page authorization of the difference, this article is mainly to share with you to restrict the page can only be opened in the built-in browser instance method, hope to help everyone.

  1. List Contents

  2. 2.

<script type= "Text/javascript" >     //The useragent of the browser is matched in regular, without the unique identity of the other browser     var useragent = navigator.useragent;     if (Useragent.match (/micromessenger/i) = ' Micromessenger ') {         //Here warning box will block the current page continue loading         alert (' This visit has been banned: You must use the built-in browser to access this page! ');         The following code is forcibly closing the current page with JavaScript         var opened = window.open (' About:blank ', ' _self ');         Opened.opener = null;         Opened.close ();     } </script>
The front end is best not to use UA to determine whether it is a built-in browser, because it is too easy to forge. This determines if (typeof Weixinjsbridge!== "undefined") {  return true;  }

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.