Android知识Android开发经验谈Android

Andoid中WebView在本地与Html中JS相互调用

2016-08-08  本文已影响264人  genylife
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Document</title>
        <script>
            function test(str) {
                document.getElementById("ttt").innerHTML = str;
                alert("1");
            }
        </script>
    </head>
    <body>
    <div>
        <a href="#" id="ttt" onclick="javascript:DEMO.functionTest()">Click Me 中文会乱码吗</a>
    </div>
    </body>
    </html>
```java
mWebView.setWebChromeClient(new WebChromeClient(){
        @Override
        public boolean onJsAlert(WebView view, String url, String message, JsResult result)
        {
            return super.onJsAlert(view, url, message, result);
        }
    });
```

至此,JS相互调用也就差不多了,有问题欢迎联系我。

上一篇 下一篇

猜你喜欢

热点阅读