views:

68

answers:

2
<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?

+3  A: 

window is the javascript window object:

The window object represents an open window in a browser.

window.demo means that a demo object has been assigned as a property (or instance variable) of window, so window.demo.clickOnAndroid() means that you are invoking clickOnAndroid() on the window's demo. Therefore demo is 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 like window.serious.clickOnAndroid().

karim79
A: 

Window is one of the top level DOM objects(1)(2). Demo is a non standard property implemented by Android.

C. Ross