<!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>
原文:http://www.cnblogs.com/lsl8966/p/4992763.html