Page 259 - Web_Application_v2.0_C12_Fb
P. 259

Output:



















                 Example 64: To demonstrate the use of  sqrt() method

                    <!DOCTYPE HTML>
                    <HTML>
                    <HEAD>
                    <TITLE>JavaScript Square Root</TITLE>
                    </HEAD>
                    <SCRIPT>
                    function display() {
                    var sqrtValue = Math.sqrt(25);
                    alert("Square root of 25: " + sqrtValue);
                    }
                    </SCRIPT>
                    </HEAD>
                    <BODY>
                    <INPUT type="button" onclick="display()" value="Find Square Root">
                    </BODY>
                    </HTML>
                 Output:




















                   2.14 JAVASCRIPT EVENTS


                 The way that JavaScript interacts with HTML is through events that happen whenever a user or browser
                 modifies a page. A page load is referred to as an event. An event also occurs when a user clicks a button. The
                 actions of pushing any key, closing a window, resizing a window, etc. are other instances.

                                                                                                  JavaScript Part 2  257
   254   255   256   257   258   259   260   261   262   263   264