JavaScript

JavaScript is a object-based scripting language. It is lightweight and cross-platform programming language.
It is not compiled but translated. JavaScript Translator (embedded in browser) is responsible to translate the JavaScript code.
Where it is used?
It is used to create interactive websites. It is mainly used for:
- Client-side validation
- Dynamic drop-down menus
- Displaying data and time
- Displaying popup windows and dialog boxes (like alert dialog box, confirm dialog box and prompt dialog box)
- Displaying clocks etc.
Audience
We have developed this tutorial for beginners as well as experienced persons. There are given a lot of examples with point to point explanation.
Problem
If there is any problem related to JavaScript, you can post your question in forum. We will definitely sort out your problems.
Understanding HTML/DOM events for Javascript
- HTML/DOM Events
Javascript code is executed with events. So before learning javascript, let’s have some idea about events.
| Events | Description |
|---|---|
| onclick | occurs when element is clicked. |
| ondblclick | occurs when element is double-clicked. |
| onfocus | occurs when an element gets focus such as button, input, textarea etc. |
| onblur | occurs when form looses the focus from an element. |
| onsubmit | occurs when form is submitted. |
| onmouseover | occurs when mouse is moved over an element. |
| onmouseout | occurs when mouse is moved out from an element (after moved over). |
| onmousedown | occurs when mouse button is pressed over an element. |
| onmouseup | occurs when mouse is released from an element (after mouse is pressed). |
| onload | occurs when document, object or frameset is loaded. |
| onunload | occurs when body or frameset is unloaded. |
| onscroll | occurs when document is scrolled. |
| onresized | occurs when document is resized. |
| onreset | occurs when form is reset. |
| onkeydown | occurs when key is being pressed. |
| onkeypress | occurs when user presses the key. |
| onkeyup | occurs when key is released.Javascript Example
Let’s create the first javascript example.
The text/javascript is the content type that provides information to the browser about the data. The document.write() function is used to display dynamic content through javascript. We will learn about document object in deail later. 3 Place to put javascript code
1) Javascript code between the body tag of htmlIn the above example, we have displayed the dynamic content using javascript. Let’s see the simple example of javascript that displays alert dialog box.
2) Javascript code between the head tag of htmlLet’s see the same example of displaying alert dialog box of javascript that is contained inside the head tag.In this example, we are creating a function msg(). To create function in javascript, you need to write function with functionname as given below. To call function, you need to work on event. Here we are using onclick event to call msg() function.
|
No comments:
Post a Comment