Android Question Call JavaScript in WebView from B4A code

dZouL IT

Member
Licensed User
Longtime User
Hi,

Anybody knows how to call JavaScript in WebView (using AJWebKit library) from B4A code.

I would like to blink specific image as what the HTML code below does. The JavaScript will be call from pop-up panel in the same activity.
B4X:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript">
var blinkImg = function (imgname, s) {
    clearTimeout(blinkImg['blinking' + imgname]);
    var obj = document.images[imgname];
    if (arguments[1] === 'blink') {
        obj.style.visibility = !(blinkImg[s + imgname] = !blinkImg[s + imgname])? '' : 'hidden';
        blinkImg['blinking' + imgname] = setTimeout(function(){blinkImg(imgname, s);}, 350);
    }
    else {
        blinkImg['blink' + imgname] = false;
        obj.style.visibility = '';
    }
};
</script>
</head>
<body>
<img name="blinker1" src="some.gif"><br>
<input type="button" onclick="blinkImg('blinker1', 'blink');" value="Blink">
<input type="button" onclick="blinkImg('blinker1', 'stop');" value="Stop">
</body>
</html>

Many thanks for help given.
 
Top