Build in Objects In JavaScript, almost "everything" is an object.

Slides:



Advertisements
Similar presentations
JavaScript Part 6. Calling JavaScript functions on an event JavaScript doesn’t have a main function like other programming languages but we can imitate.
Advertisements

Chapter 7 © 2001 by Addison Wesley Longman, Inc. 1 Chapter 7 Sebesta: Programming the World Wide Web.
Javascript II Expressions and Data Types. 2 JavaScript Review programs executed by the web browser programs embedded in a web page using the script element.
The Information School of the University of Washington Oct 20fit programming1 Programming Basics INFO/CSE 100, Fall 2006 Fluency in Information Technology.
Introduction to JavaScript. Aim To enable you to write you first JavaScript.
WEB DESIGN AND PROGRAMMING Introduction to Javascript.
JavaScript Defined DOM (Document Object Model) General Syntax Body vs. Head Variables Math & Logic Selection Functions & Events Loops Animation Getting.
Event Handlers CS101 Introduction to Computing. Learning Goals Learn about event handlers Determine how events are useful in JavaScript Discover where.
CNIT 133 Interactive Web Pags – JavaScript and AJAX JavaScript Environment.
JavaScript Lecture 6 Rachel A Ober
Week 9 PHP Cookies and Session Introduction to JavaScript.
Javascript. Outline Introduction Fundamental of JavaScript Javascript events management DOM and Dynamic HTML (DHTML)
INTRODUCTION TO JAVASCRIPT AND DOM Internet Engineering Spring 2012.
CHAPTER 4 Java Script อ. ยืนยง กันทะเนตร คณะเทคโนโลยีสารสนเทศและการสื่อสาร มหาวิทยาลัยพะเยา 1.
Using Client-Side Scripts to Enhance Web Applications 1.
Extending HTML CPSC 120 Principles of Computer Science April 9, 2012.
JavaScript, jQuery, and Mashups Incorporating JavaScript, jQuery, and other Mashups into existing pages.
JavaScript. JavaScript is the programming language of HTML and the Web. Easy to learn One of the 3 languages of all developers MUST learn: 1. HTML to.
4. Javascript M. Udin Harun Al Rasyid, S.Kom, Ph.D Lab Jaringan Komputer (C-307) Desain.
Making dynamic pages with javascript Lecture 1. Java script java versus javascript Javascript is a scripting language that will allow you to add real.
JavaScript Defined DOM (Document Object Model) General Syntax Body vs. Head Variables Math & Logic Selection Functions & Events Loops Animation Getting.
1 Javascript CS , Spring What is Javascript ? Browser scripting language  Dynamic page creation  Interactive  Embedded into HTML pages.
Introduction to JavaScript CSc 2320 Fall 2014 Disclaimer: All words, pictures are adopted from “Simple JavaScript”by Kevin Yank and Cameron Adams and also.
Javascript Overview. What is Javascript? May be one of the most popular programming languages ever Runs in the browser, not on the server All modern browsers.
JavaScript. JavaScript Introduction JavaScript is the world's most popular programming language. It is the language for HTML and the web, for servers,
Document Object Model Nasrullah. DOM When a page is loaded,browser creates a Document Object Model of the Page.
JavaScript Events Java 4 Understanding Events Events add interactivity between the web page and the user You can think of an event as a trigger that.
Javascript Basic Concepts Presentation By: Er. Sunny Chanday Lecturer CSE/IT RBIENT.
JavaScript and Ajax (JavaScript Environment) Week 6 Web site:
JavaScript Events. Understanding Events Events add interactivity between the web page and the user Events add interactivity between the web page and the.
Client-side (JavaScript) Validation. Associating a function with a click event – Part 1 Use the input tag’s onclick attribute to associate a function.
REEM ALMOTIRI Information Technology Department Majmaah University.
Third lecture Event 27/2/2016 JavaScript Tutorial.
Servlets What is a Servlet?
CGS 3066: Web Programming and Design Spring 2017
Java Script Introduction. Java Script Introduction.
Javascript and Dynamic Web Pages: Client Side Processing
Web Systems & Technologies
Chapter 6 JavaScript: Introduction to Scripting
JavaScript is a programming language designed for Web pages.
JavaScript Event Handling.
EXCEPTION HANDLING IN SERVER CLIENT PROGRAMMING
Intro to JavaScript CS 1150 Spring 2017.
Introduction to Web programming
Web Development & Design Foundations with HTML5 7th Edition
Scope, Objects, Strings, Numbers
JavaScript Functions.
4. Javascript Pemrograman Web I Program Studi Teknik Informatika
14 A Brief Look at JavaScript and jQuery.
DHTML.
JavaScript an introduction.
DHTML Javascript Internet Technology.
DHTML Javascript Internet Technology.
INFO/CSE 100, Spring 2005 Fluency in Information Technology
Functions, Regular expressions and Events
INFO/CSE 100, Spring 2006 Fluency in Information Technology
2017, Fall Pusan National University Ki-Joune Li
JavaScript MCS/BCS.
Javascript.
E-commerce Applications Development
Events: Changed and Input
Code Topic 9 Standard JavaScript Events Laura Friedman
Tutorial 10: Programming with javascript
JavaScript Basics What is JavaScript?
JavaScript is a scripting language designed for Web pages by Netscape.
The <script> Tag
Web Programming and Design
Web Programming and Design
Introduction to Web programming
Presentation transcript:

Build in Objects In JavaScript, almost "everything" is an object. -> Booleans can be objects (if defined with the new keyword) -> Numbers can be objects (if defined with the new keyword) -> Strings can be objects (if defined with the new keyword) -> Dates are always objects -> Maths are always objects -> Regular expressions are always objects -> Arrays are always objects -> Functions are always objects -> Objects are always objects

JavaScript Primitives. A primitive value is a value that has no properties or methods. A primitive data type is data that has a primitive value. JavaScript defines 5 types of primitive data types: -> string -> number -> boolean -> null -> undefined

Value Type Comment "Hello" string "Hello" is always "Hello" 3.14 number 3.14 is always 3.14 true boolean true is always true false false is always false null null (object) null is always null undefined undefined is always undefined

JavaScript Form Validation HTML form validation can be done by JavaScript. If a form field (fname) is empty, this function alerts a message, and returns false, to prevent the form from being submitted:

Example Programe JavaScript variables can contain single values: <!DOCTYPE html> <html> <body> <p>Creating a JavaScript Variable.</p> <p id="demo"></p> <script> var person = "John Doe"; document.getElementById("demo").innerHTML = person; </script> </body> </html> OUTPUT : Creating a JavaScript Variable. John Doe

Objects are variables too. But objects can contain many values Objects are variables too. But objects can contain many values. The values are written as name : value pairs (name and value separated by a colon). <!DOCTYPE html> <html> <body> <p>Creating a JavaScript Object.</p> <p id="demo"></p> <script> var person = { firstName : "John", lastName : "Doe", age : 50, eyeColor : "blue" }; document.getElementById("demo").innerHTML = person.firstName + " " + person.lastName; </script> </body> </html> Output : Creating a JavaScript Object. John Doe 50

Event Handler An HTML event can be something the browser does, or something a user does. Here are some examples of HTML events: -> An HTML web page has finished loading -> An HTML input field was changed -> An HTML button was clicked Often, when events happen, you may want to do something.

HTML allows event handler attributes, with JavaScript code, to be added to HTML elements. With single quotes: <some-HTML-element some-event='some JavaScript'> With double quotes: <some-HTML-element some-event="some JavaScript">

In the following example, an onclick attribute (with code), is added to a button element: <!DOCTYPE html> <html> <body> <button onclick="document.getElementById('demo').innerHTML=Date()">The time is?</button> <p id="demo"></p> </body> </html> Output :

DHTML Three Important Concepts involved in DHTML JavaScript Alone JavaScript and the HTML DOM JavaScript and HTML Events JavaScript and CSS

JavaScript Alone document.write() <html> <body> <script type="text/javascript"> document.write(Date()); </script> </body> </html>

JavaScript and the HTML DOM With HTML 4, JavaScript can also be used to change the inner content and attributes of HTML elements dynamically. To change the content of an HTML element use: document.getElementById(id).innerHTML=new HTML To change the attribute of an HTML element use: document.getElementById(id).attribute=new value

JavaScript and HTML Events To execute code when a user clicks on an element, use the following event attribute: onclick=JavaScript

JavaScript and CSS To change the style of an HTML element use: document.getElementById(id).style.property=new style

Thank You,