• APP中关于Android和IOS与网页交互


    安卓交互:

        //安卓js代码start
        function bntcat(){
            if(isAndroid){
                musicPause()
            }
            var str = '{"tips":2018,"type":3}';
            JsCallback.jsMethod(str);
        }
        //安卓js代码end
    

    IOS交互:

        //ios js代码start
        /****************************ios固定写法start**********************************/
        function setupWebViewJavascriptBridge(callback) {
            if (window.WebViewJavascriptBridge) {
                return callback(WebViewJavascriptBridge);
            }
            if (window.WVJBCallbacks) {
                return window.WVJBCallbacks.push(callback);
            }
            window.WVJBCallbacks = [callback];
            var WVJBIframe = document.createElement('iframe');
            WVJBIframe.style.display = 'none';
            WVJBIframe.src = 'wvjbscheme://__BRIDGE_LOADED__';
            document.documentElement.appendChild(WVJBIframe);
            setTimeout(function () {
                document.documentElement.removeChild(WVJBIframe)
            }, 0)
        }
        /****************************ios固定写法end**********************************/
        setupWebViewJavascriptBridge(function (bridge) {
            $(".xxxxxx").click(function(){
                var id= $(this).data("id"),
                str = '{"tips":2018,"type":1,"gid":'+id+'}';           
                bridge.callHandler('nhjGoodsDetails', str, function (responseData) {})
            });
            bridge.registerHandler('miusicPlay', function (data, responseCallback) {
                $("#playAudio").addClass('on');
                document.getElementById("myaudio").play();
                responseCallback({'userId': '123456', 'blog': 'miusicPlay'})
            });
            bridge.registerHandler('miusicPause', function (data, responseCallback) {
                $("#playAudio").removeClass('on');
                document.getElementById("myaudio").pause();
            })
        });
        //ios js代码end
    

      

  • 相关阅读:
    Java实现 LeetCode 715 Range 模块(选范围)
    HTML 图像
    HTML 样式- CSS
    HTML <head>
    HTML 链接
    HTML 文本格式化
    目标检测中的anchor-based 和anchor free
    目标检测coco数据集点滴介绍
    Camera HDR Algorithms
    噪声标签的负训练:ICCV2019论文解析
  • 原文地址:https://www.cnblogs.com/mracale/p/8674344.html
Copyright © 2020-2023  润新知