首页 > 移动平台 > 详细

h5页与ios通信

时间:2017-02-04 16:24:55      阅读:266      评论:0      收藏:0      [点我收藏+]

直接上代码 1 粘第一段

//ios
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)
}
setupWebViewJavascriptBridge(function(bridge) {
    iapp.sidebar.delegate("li","touchend",function(event){
        var $this = $(this);
        var index = $this.index();
        var point = {
            0:function(){
                bridge.callHandler(‘CallHandlerID‘, {‘key‘: ‘患者‘}, function(response){
                       
                })
            },
            1:function(){
                bridge.callHandler(‘CallHandlerID‘, {‘key‘: ‘疾病‘}, function(response){
                       
                })
            },
            2:function(){
                bridge.callHandler(‘CallHandlerID‘, {‘key‘: ‘检测史‘}, function(response){
                       
                })
            },
            3:function(){
                bridge.callHandler(‘CallHandlerID‘, {‘key‘: ‘家族史‘}, function(response){
                       
                })
            },
            4:function(){
                 bridge.callHandler(‘CallHandlerID‘, {‘key‘: ‘用药史‘}, function(response){
                       
                })
            }

        }

        point[index]();
        
    })
 })

需求还是挺简单的 点击了那个菜单就穿那个菜单名过去

https://github.com/marcuswestin/WebViewJavascriptBridge

h5页与ios通信

原文:http://www.cnblogs.com/junwu/p/6365617.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!