I have tried pass the parameter from javascript to android but it return
01-08 20:32:17.214: D/WebConsole(27791): Uncaught Error: Error calling method on NPObject. -- From line 433 of file:///data/data/com.test/files/HK/news_list.html
My code is like the following
Js:
function changeSection(){
//var pos = parseInt($(this).attr("data-index"),10);
var pos = 2;
if (pos == 3){
window.location.href="video_list.html";
} else {
window.location.href="news_list.html?target="+$(this).attr("target")+"&type="+$(this).attr("type");
}
window.jsinterface.highLightLeftMenu(2);
}
The code that build up the button link:
if(target+'_'+pageType == LMenu[k]['sid']){
sectionMenu += "<div class='focus' data-index='"+k+"' target='"+tmpArr[0]+"' type='"+tmpArr[1]+"' onclick=\"changeSection()\">"+LMenu[k]['name']+"</div>";
}else{
sectionMenu += "<div data-index='"+k+"' onclick=\"changeSection()\">"+LMenu[k]['name']+"</div>";
}
Android:
mWebView.addJavascriptInterface(this, "jsinterface");
public void highLightLeftMenu(int pos) {
Log.d("test1","aa");
Log.d("test1","bb" + pos);
MainActivity.highLightLeftMenu(pos);
}
It can log out the aa and bb with pos in android , but return the error message in the webview, also, how to pass the integer in js/jquery to android without hard coding ? thanks