webview调用javascript获得返回值5

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>test</title>
<script type="text/javascript">
function test_function_add(a,b)
{
	return a+b;
}
function android_ret(tag,val)
{
	alert(tag+":"+val);
}
function android_excute(tag,js)
{
	var retval = eval(js);
	android_ret(tag,retval);
}
function getCellString(row, column) 
{
	return Report.getCellString(row,column);
}
function getCookie(name)//取cookies函数           
{   
    var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));   
     if(arr != null){   
    		test.getCookie(name,unescape(arr[2]));  
     }else{
     		test.getCookie(name,"null");   
     } 
}
</script>
</head>

<body>
</body>
</html>


安卓中,想要调用html里面的方法,并且获得返回值。应该怎么去获得?

webView.loadUrl("javascript:android_excute('test','test_function_add(1,6)'");
  webView.addJavascriptInterface(new JavaScriptInterface(), "Report");
  webView.loadUrl("javascript:getCellString('Report',getCellString(5,7)");

这样都获得不了。麻烦问下具体应该怎样去获得

猜你喜欢

转载自awwv.iteye.com/blog/1631780