Created
September 3, 2014 06:28
-
-
Save agassiyzh/7d1b4d8d9669d339d974 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
</head> | |
<body style="width: 320px"> | |
<script> | |
window.onerror = function(err) { | |
} | |
function connectWebViewJavascriptBridge(callback) { | |
if (window.WebViewJavascriptBridge) { | |
callback(WebViewJavascriptBridge) | |
} else { | |
document.addEventListener('WebViewJavascriptBridgeReady', function() { | |
callback(WebViewJavascriptBridge) | |
}, false) | |
} | |
} | |
connectWebViewJavascriptBridge(function(bridge) { | |
bridge.init(function(message, responseCallback) { | |
if (responseCallback) { | |
responseCallback("Right back atcha") | |
} | |
}) | |
bridge.registerHandler('payForAlipay', function(data, responseCallback) { | |
var responseData = { 'Javascript Says':'Right back atcha!' } | |
responseCallback(responseData) | |
}) | |
var button = document.getElementById('btn') | |
button.onclick = function(e) { | |
e.preventDefault() | |
var data = { | |
"tradeNO" : "58123", | |
"price" : "0.01", | |
"productName" : "Minila Air", | |
"productDescription" : "Buletooth", | |
"notifyURL" : "http://qiugonglue.com" | |
} | |
bridge.callHandler("payForAlipay",data, function(responseData) { | |
alert("I got a response!") | |
responseCallback(responseData) | |
}) | |
} | |
}) | |
</script> | |
<button id='btn'>click me</button> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment