html 코드에 자바스크립트를 넣고 기능을 수행하려합니다.
아래와 같이 html 코드와 자바스크립트를작성하였고,
같은 class에 자바스크립트 동작 수행 함수를 넣어놓았는데,
동작이 되지가 않고 있네요..;
뭘 잘못했을까요?
===== html 코드 ======
<html>
<head>
<meta http-equiv='Content-Type' content='text/html charset=utf-8'>
// 자바스크립트 코드
<script type='text/javascript'>
function mrv(image)
{window.android.onAdImageReceived();}
function clickclosebutton(image)
{window.android.onCloseButtonClick();}
function err()
{window.android.onAdImageFailed();}
var div_adimg = document.getElementById('adimg');
div_adimg=null;
</script>
</head>
<body style='margin:0;'>
<div id='adimg' style='position:absolute' z-index='2'>
<img style='margin:0;' src='http://서버주소/Sites/1st/test.png' onload='mrv(this);' onerror='err();'/>
</div>
<div style='position:absolute' z-index='1'>
<img src=" 'file:///android_res/drawable/close_button.png' alt='close' onclick='clickclosebutton(this)';/>
</div>
</body>
</html>
========== 자바 코드 ===================
=== 처음 세팅 ===
webview.getSettings().setJavaScriptEnabled(true);
webview.addJavascriptInterface(new JavascriptInterface(),"android");
= 동작 코드 ===
public class JavascriptInterface{
public void onAdImageFailed()
{
callFinish();
}
public void onCloseButtonClick()
{
callFinish();
}
public void onAdImageReceived(){
try {
Log.i("INT", "imageReceiveError
} catch (Exception e) {
Log.i("INT", "imageReceiveError");
}
}
}