随笔 - 159  文章 - 2  评论 - 0  阅读 - 61806

ios jsbrige

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <title>{$data.title}</title>
    <meta name="viewport" content="user-scalable=no,width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <meta name="description" content="">
    <meta name="keywords" content="">
    <meta name="author" content="">
    <style type="text/css">
        html {
            font-size: 62.5%;/*10 ÷ 16 × 100% = 62.5%*/
        }
        body {
            font-size: 14px;;
            margin: 0 auto;
            font-weight: bold;
            overflow-x: hidden;
            letter-spacing: 0.1rem;/*1.4 × 10px = 14px */
            padding:10px;
            line-height:26px;
            background: rgb(230,230,230);
            color: #666666;
        }
        h1 {
            font-size: 2.4rem;/*2.4 × 10px = 24px*/
        }
        h3 {
            font-size: 1.8rem;
        }
        #buttons a{border: 1px solid #FF4500;color:#FF4500; text-decoration: none;  padding: 5px;}
    </style>
 
</head>
 <body>
    <div class="banner">
        <img src="http://service.zx7c.cn/2013/{$data.image}">
    </div>
    <p>
        <script>
            window.onerror = function(err) {
                log('window.onerror: ' + err)
            }
            function connectWebViewJavascriptBridge(callback) {
                if (window.WebViewJavascriptBridge) {
                    callback(WebViewJavascriptBridge)
                } else {
                    document.addEventListener('WebViewJavascriptBridgeReady', function() {
                        callback(WebViewJavascriptBridge)
                    }, false)
                }
            }
 
            connectWebViewJavascriptBridge(function(bridge) {
                var uniqueId = 1
                function log(message, data) {
//                var log = document.getElementById('log')
//                var el = document.createElement('div')
//                el.className = 'logLine'
//                el.innerHTML = uniqueId++ + '. ' + message + ':<br/>' + JSON.stringify(data)
//                if (log.children.length) { log.insertBefore(el, log.children[0]) }
//                else { log.appendChild(el) }
                }
                bridge.init(function(message, responseCallback) {
                    log('JS got a message', message)
                    var data = { 'Javascript Responds':'Wee!' }
                    log('JS responding with', data)
                    responseCallback(data)
                })
 
                bridge.registerHandler('testJavascriptHandler', function(data, responseCallback) {
                    log('ObjC called testJavascriptHandler with', data)
                    var responseData = { 'Javascript Says':'Right back atcha!' }
                    log('JS responding with', responseData)
                    responseCallback(responseData)
                })
 
                //测试回调
                var callbackButton = document.getElementById('buttons')
                callbackButton.onclick = function(e) {
                    e.preventDefault()
                    log('JS calling handler "testObjcCallback"')
 
                    bridge.callHandler('testObjcCallback', {'m_id': '<php>echo $data["m_id"];</php>'}, function(response) {
                        log('JS got response', response)
                    })
                }
            })
        </script>
        {$data.content}
    </p>
    <if condition="$data['m_id'] neq 0">
        <div id='buttons'>价格:500元 <a href="#">查看详情</a><div id='log'></div> </div>
    </if>
 </body>
</html>

  

posted on   lsl8966  阅读(235)  评论(0编辑  收藏  举报
编辑推荐:
· Linux glibc自带哈希表的用例及性能测试
· 深入理解 Mybatis 分库分表执行原理
· 如何打造一个高并发系统?
· .NET Core GC压缩(compact_phase)底层原理浅谈
· 现代计算机视觉入门之:什么是图片特征编码
阅读排行:
· 手把手教你在本地部署DeepSeek R1,搭建web-ui ,建议收藏!
· Spring AI + Ollama 实现 deepseek-r1 的API服务和调用
· 数据库服务器 SQL Server 版本升级公告
· 程序员常用高效实用工具推荐,办公效率提升利器!
· C#/.NET/.NET Core技术前沿周刊 | 第 23 期(2025年1.20-1.26)
< 2025年1月 >
29 30 31 1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31 1
2 3 4 5 6 7 8

点击右上角即可分享
微信分享提示