Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javascript question--what is "window"?

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

like image 930
TIMEX Avatar asked Oct 15 '22 10:10

TIMEX


1 Answers

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().

like image 183
karim79 Avatar answered Oct 17 '22 02:10

karim79