zoukankan      html  css  js  c++  java
  • h5分享到微信,分享到朋友圈

    如果直接用浏览器打开的话,会出现这个错误。要用Android系统打开才行
    <body>
        <div id="makeMoney_sharewx">分享到微信</div>
        <div id="makeMoney_sharewxf">分享到朋友圈</div>
    </body>
     
    <script src="../js/jquery.min.js"></script>
    <script>
        $('#makeMoney_sharewx').click(function() {
            if (window.navigator.userAgent.toLowerCase().indexOf("micromessenger") !== -1) {} else {
                if (!!window.navigator.userAgent.match(/(i[^;]+;( U;)? CPU.+Mac OS X/) || !!window.navigator.userAgent.match(/(M[^;]+;( l;)? Intel.+Mac OS X/)) {
                    var tmp = {};
                    tmp.copyValue = title;
                    window.webkit.messageHandlers.copy.postMessage(tmp);
                    var para = {};
                    para.aid = aid;
                    para.type = "weixin";
                    window.webkit.messageHandlers.share.postMessage(para);
                } else {
                    Android.copy(title);
                    try {
                        Android.share(aid, "weixin", "true"); // 使用自己的appid分享文章
                    } catch (e) {
                        Android.share(aid, "weixin");
                    }
                }
            }
        });

        $('#makeMoney_sharewxf').click(function() {
            if (window.navigator.userAgent.toLowerCase().indexOf("micromessenger") !== -1) {} else {
                if (!!window.navigator.userAgent.match(/(i[^;]+;( U;)? CPU.+Mac OS X/) || !!window.navigator.userAgent.match(/(M[^;]+;( l;)? Intel.+Mac OS X/)) {
                    var tmp = {};
                    tmp.copyValue = title;
                    window.webkit.messageHandlers.copy.postMessage(tmp);

                    var para = {};
                    para.aid = aid;
                    para.type = "weixinFriend";
                    window.webkit.messageHandlers.share.postMessage(para);
                } else {
                    Android.copy(title);

                    try {
                        Android.share(aid, "weixinFriend", "true"); // 使用自己的appid分享文章
                    } catch (e) {
                        Android.share(aid, "weixinFriend");
                    }
                }
            }
        });
    </script>
     
  • 相关阅读:
    数组塌陷现象
    深浅拷贝的区别
    冒泡排序,选择排序的应用
    JavaScript双重循环的嵌套
    Css Grid网格布局
    css3动画详细介绍
    Python tkinter Label Widget relief upload image
    XXXFD
    XXX1
    Python爬取一个简单网页的HTML代码
  • 原文地址:https://www.cnblogs.com/putaopi/p/12030826.html
Copyright © 2011-2022 走看看