Master Javascript by Typing Part 1
A series by Pramod S Nair for Wisdombay (originally published in www.spidercreationsindia.com)

Analysing the code
The events are controlled by using Event handlers like onClick, onLoad
etc. We will discuss them in detail later. Here the key code segment
is the line
<input type="button" value="Click Me"
onClick='alert("Yes Sir")'>
here we are creating a button and are adding a handler to it. The
handler is added by writing the onClick event handler in the <input>
tag. So when a click event is made on the button the code that is
specified for onClick gets executed.
You can include JavaScript commands into a particular part of the page. This is useful if, for example, if you’d like JavaScript to write text directly into the browser. The following code is an example.
|
|
Launch your Text Editor, type the above given code & save as second.html
(or any other name you prefer). Now view the file that you created
in browser & you will see a small button in the page. Clicking
on the button will launch a dialog box that displays the message that
you gave as parameter to the alert() function.

Analysing the code
Even though the code look a bit cryptic to newbies, just concentarte
on , this statement is used to write to the
browser from a code block. The other things i will explain when you
get enough exposure to DOM (Document Object Model) & OOPS( Object
Oriented Programming). We will discuss them in later issues. In this
third option of incorporating javascript you write the code just like
you did in the first section. ie, between <script> & </script>
document.write ("Today is " + dt + " / " + m +
" / " + y)
SO WE CONCLUDE OUR FIRST PART HERE.
