<html>
<script language="javascript">
/* This function is invoked by the activity */
function wave() {
alert("1");
document.getElementById("droid").src="android_waving.png";
alert("2");
}
</script>
<body>
<!-- Calls into the javascript interface for the activity -->
<a onClick="window.demo.clickOnAndroid()"><div style="width:80px;
margin:0px auto;
padding:10px;
text-align:center;
border:2px solid #202020;" >
<img id="droid" src="android_normal.png"/><br>
Click me!
</div></a>
</body>
</html>
My question is: What is “window.demo.clickOnAndroid()”?
I know that clickOnAndroid is a method in my Android application. But what is window and demo? My file is called demo.html. Is that it?
windowis the javascript window object:window.demomeans that ademoobject has been assigned as a property (or instance variable) ofwindow, sowindow.demo.clickOnAndroid()means that you are invokingclickOnAndroid()on thewindow‘sdemo. Thereforedemois the name of the instance of your Android application, your real application would be up to you to name, so your invocation would probably look likewindow.serious.clickOnAndroid().