2013.09.23——— android js调用

2013.09.23——— android js调用
参考: http://liaokang-java.iteye.com/blog/1168832
http://blog.csdn.net/ithomer/article/details/8737999


mWeb.getSettings().setJavaScriptEnabled(true);
mWeb.addJavascriptInterface(new Object(){
				public String test(){
					return AppKernelManager.jOBaseKernel.Encrypt("123456");
				}
		}, "test");
//加载assets目录下的文件  
String url = "file:///android_asset/test.html";  
mWeb.loadUrl(url); 



html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
  <title></title>
    <script type="text/javascript">
        function testFun()
        {
            var tStr = window.test.test();
			alert(tStr);
        }

    </script>
</head>
<body onload="testFun()">
      <table id="contact">
          <tr>
              <td>111</td>
              <td>222</td>
              <td>333</td>
          </tr>
      </table>
</body>
</html>




猜你喜欢

转载自trylovecatch.iteye.com/blog/1946059