• Course Code: 22519 • Rationale: This course helps students to create highly interactive web pages using the features of JavaScript. • Competency: The aim of this course is to help the student to attain the following industry identified competency through various teaching learning experiences – Develop dynamic web pages using JavaScript • Course Outcomes: a. Create interactive web pages using program flow control structure b. Implement Arrays and functions using Java script c. Create event based web forms using Java script d. Use Java script for handling cookies e. Create interactive web page using regular expressions for validations f. Create menus and navigations in web pages OUTLINE • Features of Java script
• Object Name, property, method, dot syntax,
main event
• Values and variables
FEATURES OF JAVA SCRIPT • JavaScript is limited featured client side programming language • JavaScript runs at the client end through user’s web browser • It is widely used by web developers to build dynamic web pages, respond to events, create interactive forms, validate the data entered into the form, control the web browser etc. • JavaScript is both scripting and programming language • JavaScript programs called scripts are included in a web page using <script> HTML tag • Browser downloads the JavaScript, when the web page is downloaded • The JavaScript program cannot access your computer’s hard disk • JavaScript is Netscape creation FEATURES OF JAVA SCRIPT
You can do following things using JavaScript which you cannot
do using HTML:
• Build dynamic web pages
• Display alert boxes • Write messages to the browser status bar • Control features of the browser • Open new browser windows • Customize reactions to mouse actions and keystrokes FEATURES OF JAVAS SCRIPT
• Validate information in forms
• Perform calculations • Display messages when cursor rolls over an object on the screen • Create interactive forms • Set date and time • Identify the browsers and browser plug-ins such as Flash FEATURES OF JAVA SCRIPT Although JavaScript is more powerful than HTML it cannot do following things: • Write files to your hard disk • Read files from your hard disk- except for cookies • Close windows other than those the JavaScript application opened • Write server side applications called CGI applications • Read information from a web page that resides on a domain different from the domain where JavaScript resides OBJECT NAME, PROPERTY, METHOD • JavaScript is an Object Oriented Programming Language • The most commonly used objects by JavaScript: documents, forms, fields, radio button, window etc. • Each object must be uniquely identified by name or ID that you assign to your object to reference it from your JavaScript • Property is a value that is associated with an object • Each kind of object has its own set of properties • Method is a process performed by an object when it receives a message DOT SYNTAX • You can access object’s properties and methods using dot syntax along with the object name and its property or method • For example, background color of a document can be accessed as: document.bgcolor and write method for a document can be accessed as: document.write() MAIN EVENT
• An event causes your JavaScript to start executing the code
• JavaScript should react to important events which is called as event handling • You can create an event handler, which is a part of your JavaScript that reacts to important events FIRST JAVASCRIPT <html> <head> <title> First JavaScript </title> </head> <body> <script language=“javascript"> document.write(“Welcome to Java script programming”); </script> </body> </html> VALUES AND VARIABLES • Variable is a placeholder that holds spot for data that can be changed during the execution of program • JavaScript uses six kinds of values: -number -string -Boolean -null -Object -function