Skip to content

Commit 926d5db

Browse files
committed
have errors
1 parent 52b94a4 commit 926d5db

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

Android/Example/res/raw/WebViewJavascriptBridge.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,18 @@
2323
}
2424

2525
function _doSend(message, responseCallback) {
26+
console.log("sending:"+JSON.stringify(message));
2627
if (responseCallback) {
2728
var callbackId = 'cb_'+(uniqueId++)+'_'+new Date().getTime()
2829
responseCallbacks[callbackId] = responseCallback
2930
message['callbackId'] = callbackId
30-
_WebViewJavascriptBridge._handleMessageFromJs(message.data,message.responseId,
31-
message.responseData,message.callbackId,message.handlerName);
32-
}
31+
}
32+
_WebViewJavascriptBridge._handleMessageFromJs(message.data,message.responseId,
33+
message.responseData,message.callbackId,message.handlerName);
34+
3335
}
3436

35-
function _dispatchMessageFromJAVA(messageJSON) {
37+
function _dispatchMessageFromJava(messageJSON) {
3638
var message = JSON.parse(messageJSON)
3739
var messageHandler
3840

@@ -80,7 +82,9 @@
8082
}
8183

8284
//dispatch event
83-
var readyEvent=new CustomEvent('WebViewJavascriptBridgeReady')
84-
readyEvent.bridge=WebViewJavascriptBridge;
85-
document.dispatchEvent(readyEvent);
85+
var doc = document;
86+
var readyEvent = doc.createEvent('Events');
87+
readyEvent.initEvent('WebViewJavascriptBridgeReady');
88+
readyEvent.bridge = WebViewJavascriptBridge;
89+
doc.dispatchEvent(readyEvent);
8690
})();

Android/Example/src/com/fangjian/WebViewJavascriptBridge.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,9 @@ public void onPageFinished(WebView webView, String url) {
7676
private class MyWebChromeClient extends WebChromeClient {
7777
@Override
7878
public boolean onConsoleMessage(ConsoleMessage cm) {
79-
Log.d("test", cm.message());
79+
Log.d("test", cm.message()
80+
+" line:"+ cm.lineNumber()
81+
);
8082
return true;
8183
}
8284

0 commit comments

Comments
 (0)