版權聲明:本文爲博主原創文章,未經博主允許不得轉載。 https://blog.csdn.net/haozhenming/article/details/53610216
下面是index.htmlx界面代碼
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
</head>
<body>
<nav title="webview和html互相調用"></nav>
<webview id="webview" width="100%" height="100%" url="local://html/my.htm" />
</body>
<script>
//webview調用html裏面的方法
webview.addEvent("onFinished" , function(){
webview.execute("changeLabelValue()");
})
webview.addEvent("onFailured" , function(){
})
function click1(data){
//html傳過來的中文會出現亂碼,所以使用解碼方法進行解碼
var string = decodeURIComponent(data);
alert(string)
}
</script>
</html>
點擊可以下載gifDemo.zip示例demo