Cordova Web View sendjavascript已弃用,但对我来说无效。 我的java代码是:
public static void sendJavascript(JSONObject _json) {
String _d = "javascript:" + gECB + "(" + _json.toString() + ")";
Log.v(TAG, "sendJavascript: " + _d);
Log.i(TAG,_d);
if (gECB != null && gWebView != null) {
gWebView.sendJavascript(_d);//deprecated method
}
}
我的java脚本代码:
document.addEventListener("deviceready", function(){
window.plugins.pushNotification.register(successHandler, errorHandler, {
ecb : 'onNotificationGCM',
senderID : 'xxxxxxxxxxxxx'
});
// Method to handle device registration for Android.
var onNotificationGCM = function(e) {
if('registered' === e.event) {
// Successfully registered device.
alert(e.regid);
}
else if('error' === e.event) {
// Failed to register device.
alert(e.msg);
}
else if('message' === e.event) {
//mesage recived
alert(e.payload.message);
}
};
// result contains any message sent from the plugin call
function successHandler (result) {
alert('gcm result = ' + result);
}
// result contains any error description text returned from the plugin call
function errorHandler (error) {
alert('error = ' + error);
}
});
请帮帮我?
答案 0 :(得分:0)
这应该适合你:
gWebView.loadUrl("javascript:myJavaScriptFuntion();");