Event Programming and JavaScript
What is event Programming?
An event, in a computing context, is an action or occurrence that can be identified by a program and has significance for system hardware or software. Events can be user-generated, such as keystrokes and mouse clicks, or system-generated, such as program loading, running out of memory and errors.
HTML cannot provide event programming and also page arrangement. With the help of JavaScript all event programmings will take place in HTML pages.
In the case of the Web, events are fired inside the browser window, and tend to be attached to a specific item that resides in it. This might be a single element, a set of elements, the HTML document loaded in the current tab, or the entire browser window. There are many different types of events that can occur.
For example:
The user selects, clicks, or hovers the cursor over a certain element.
The user chooses a key on the keyboard.
The user resizes or closes the browser window.
A web page finishes loading.
A form is submitted.
A video is played, paused, or finishes.
An error occurs.
What is JavaScript?
- It is a background language.
- It is a case sensitive language.
- JavaScript is used inside the <head>
Structure of JavaScript:
<html>
<head>
<script language="JavaScript">
...............
..............
(logic of a program)
................
...............
</script>
</head>
</html>
Note:
- In this scripting no error message display.
- Inside the <script>, we are unable to used any tag symbol used in HTML
- If we want to use tag then write as shown in below
Here attribute written with single quote and + is used for combine the statements.
Types of statements used in JavaScript:
- Output /Printing statement.
- Alert statement.
- Confirm statement.
- Input statement.
Example:
<html>
<head>
<script language="JavaScript">
document.write("<font color='red'>welcome to my program</font>" + "<br>");
document.write("Nagpur is called as orange city");
alert("welcome");
confirm("do you want to exit");
prompt("enter any numbers");
</script>
</head>
</html>
Comments
Post a Comment