zoukankan      html  css  js  c++  java
  • 判断请求是浏览器发出还是小程序发出

    直接上代码:

     <script type="text/javascript" src="https://res.wx.qq.com/open/js/jweixin-1.3.2.js"></script>
      <script type="text/javascript">
            function openMap()
            {
                 const ua = window.navigator.userAgent.toLowerCase();
                    if (ua.indexOf('micromessenger') == -1) {//不在微信或者小程序中
                            window.location.href = 'https://apis.map.qq.com/uri/v1/marker?marker=coord:31.235371,121.488571;title:国拍大楼;';
                    } else {
                        wx.miniProgram.getEnv(function (res) {
                            //true代表在小程序里
                            if (res.miniprogram) {
                                 wx.miniProgram.navigateTo({ url: '../../pages/gpmap/gpmap' })
                            }
                            else {
                                 window.open("https://api.map.baidu.com/marker?location=31.24119,121.495083&title=我的位置&content=国拍大楼&output=html")
                            }
                        })
                    }
            }
      </script>
  • 相关阅读:
    Python挂载杂记
    Python Log的使用, 模块化
    Python实现图片长宽比例缩放和填充
    系统监控与硬盘
    linux基础三
    linux基础二
    linux基础一
    网络基础
    操作系统
    计算机硬件基础
  • 原文地址:https://www.cnblogs.com/yechangzhong-826217795/p/11911362.html
Copyright © 2011-2022 走看看