-1

I have a function drawImage(json, check) in file test.js. ow I want to call this function from android code. I use cwv.loadUrl("javascript:test.drawImage("+jsonArray+","+ true+")");, but this solution doesn't work. How can I call this method from android code?

4

1 回答 1

1

您可以将 JS 函数放在外部文件中。将其放入您的 html 文件中,如下所示:

<script>
    function drawImage ()
    {
         // your computataion 
    }
</script>
// or connect your js functions from external file 
<script src="test.js"></script>

然后从代码中调用它

cwv.loadUrl("javascript:drawImage('"+jsonArray+"','"+ true+"')");

并注意单引号!

第二种方法由 Mocialov Boris 描述。

于 2013-08-07T07:00:47.653 回答