JavaScript Defined DOM (Document Object Model) General Syntax Body vs. Head Variables Math & Logic Selection Functions & Events Loops Animation Getting.

Slides:



Advertisements
Similar presentations
1 What is JavaScript? JavaScript was designed to add interactivity to HTML pages JavaScript is a scripting language A scripting language is a lightweight.
Advertisements

JavaScript FaaDoOEngineers.com FaaDoOEngineers.com.
Javascript Introduction Norman White Material is from w3schools.com Go there to run examples interactively.
The Web Warrior Guide to Web Design Technologies
14/11/11.  These words have special meanings in themselves  These should NOT be used as Identifiers.  For example:  Break, do, function, case, else,
HTML Forms JavaScript Introduction / Overview Lab Homework #1 CS 183 4/8/2010.
CS 898N – Advanced World Wide Web Technologies Lecture 14: JavaScript Chin-Chih Chang
Information Technology Center Hany Abdelwahab Computer Specialist.
CS 299 – Web Programming and Design Overview of JavaScript and DOM Instructor: Dr. Fang (Daisy) Tang.
2012 •••••••••••••••••••••••••••••••••• Summer WorkShop Mostafa Badr
JavaScript CMPT 281. Outline Introduction to JavaScript Resources What is JavaScript? JavaScript in web pages.
JS: DOM Form Form Object Form Object –The Form object represents an HTML form. –For each instance of a tag in an HTML document, a Form object is created.
JavaScript Teppo Räisänen LIIKE/OAMK HTML, CSS, JavaScript HTML defines the structure CSS defines the layout JavaScript is used for scripting It.
Introduction to JavaScript. JavaScript Facts A scripting language - not compiled but interpreted line by line at run-time. Platform independent. It is.
JavaScript Defined DOM (Document Object Model) General Syntax Body vs. Head Variables Math & Logic Selection Functions & Events Loops Animation Getting.
SEG3210 DHTML Tutorial. DHTML DHTML is a combination of technologies used to create dynamic and interactive Web sites. –HTML - For creating text and image.
Bridges To Computing General Information: This document was created for use in the "Bridges to Computing" project of Brooklyn College. You are invited.
JavaScript Part 1.
JavaScript Part 1.
JavaScript Informatics for economists I. Introduction Programming language used in web pages. Simple and easy to use – written in HTML document. Client.
DHTML: Dynamic HTML Internet Technology1. What is DHTML? A collection of enhancements to HTML ► To create dynamic and interactive websites Combination.
SEG3210 DHTML Tutorial. DHTML DHTML is a combination of technologies used to create dynamic and interactive Web sites. –HTML - For creating text and image.
Client Scripting1 Internet Systems Design. Client Scripting2 n “A scripting language is a programming language that is used to manipulate, customize,
What is Java Script? An extension to HTML. An extension to HTML. Allows authors to incorporate some functionality in their web pages. (without using CGI.
Javascript. Outline Introduction Fundamental of JavaScript Javascript events management DOM and Dynamic HTML (DHTML)
Client Side Programming with JavaScript Why use client side programming? Web sides built on CGI programs can rapidly become overly complicated to maintain,
INTRODUCTION TO JAVASCRIPT AND DOM Internet Engineering Spring 2012.
TUTORIAL 10: PROGRAMMING WITH JAVASCRIPT Session 2: What is JavaScript?
Introduction to JavaScript Basharat Mahmood, Department of Computer Science, CIIT, Islamabad, Pakistan. 1.
Extending HTML CPSC 120 Principles of Computer Science April 9, 2012.
Client-Side Scripting JavaScript.  produced by Netscape for use within HTML Web pages.  built into all the major modern browsers. properties  lightweight,
JavaScript, jQuery, and Mashups Incorporating JavaScript, jQuery, and other Mashups into existing pages.
LOGO Introduction to Client-Side Scripting and JavaScript CHAPTER 9 Eastern Mediterranean University School of Computing and Technology Department of Information.
1 JavaScript
JavaScript Syntax, how to use it in a HTML document
JavaScript Scripting language What is Scripting ? A scripting language, script language, or extension language is a programming language.
Sahar Mosleh California State University San MarcosPage 1 JavaScript Basic.
ECA 225 Applied Interactive Programming1 ECA 225 Applied Online Programming basics.
COMP403 Web Design JAVA SCRİPTS Tolgay KARANFİLLER.
4. Javascript M. Udin Harun Al Rasyid, S.Kom, Ph.D Lab Jaringan Komputer (C-307) Desain.
HTML Overview Part 5 – JavaScript 1. Scripts 2  Scripts are used to add dynamic content to a web page.  Scripts consist of a list of commands that execute.
Pertemuan 5 IT133 Pengembangan Web JavaScript. What is JavaScript? JavaScript was designed to add interactivity to HTML pages JavaScript is a scripting.
CIS 3.5 Lecture 2.3 "Introduction to JavaScript".
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 7 TH EDITION Chapter 14 Key Concepts 1 Copyright © Terry Felke-Morris.
JavaScript. JavaScript Introduction JavaScript is the world's most popular programming language. It is the language for HTML and the web, for servers,
Web Development JavaScript. Introduction to JavaScript.
Introduction to JavaScript MIS 3502, Spring 2016 Jeremy Shafer Department of MIS Fox School of Business Temple University 2/2/2016.
Javascript Basic Concepts Presentation By: Er. Sunny Chanday Lecturer CSE/IT RBIENT.
CGS 3066: Web Programming and Design Spring 2016 Introduction to JavaScript.
1 Agenda  Unit 7: Introduction to Programming Using JavaScript T. Jumana Abu Shmais – AOU - Riyadh.
COM621: Advanced Interactive Web Development Lecture 6 – JavaScript (cont.)
Introduction to JavaScript MIS 3502, Fall 2016 Jeremy Shafer Department of MIS Fox School of Business Temple University 9/29/2016.
CGS 3066: Web Programming and Design Spring 2017
Web Development & Design Foundations with HTML5
Week 4: Introduction to Javascript
JavaScript is a programming language designed for Web pages.
Web Development & Design Foundations with HTML5 7th Edition
4. Javascript Pemrograman Web I Program Studi Teknik Informatika
JavaScript.
14 A Brief Look at JavaScript and jQuery.
JavaScript an introduction.
DHTML Javascript Internet Technology.
DHTML Javascript Internet Technology.
JavaScript Defined General Syntax Body vs. Head Variables Math & Logic
Tutorial 10: Programming with javascript
JavaScript Basics What is JavaScript?
JavaScript is a scripting language designed for Web pages by Netscape.
Web Programming and Design
Web Programming and Design
Web Programming and Design
Presentation transcript:

JavaScript Defined DOM (Document Object Model) General Syntax Body vs. Head Variables Math & Logic Selection Functions & Events Loops Animation Getting Help

What is JavaScript? 1.JavaScript is NOT Java! 2.JavaScript was designed to add interactivity to HTML pages 3.JavaScript is a scripting language 4.JavaScript is usually embedded directly into HTML pages 5.JavaScript is an interpreted language (means that scripts execute without preliminary compilation) 6.JavaScript is free and open-source

What can a JavaScript do? 1.JavaScript gives HTML designers a programming tool (very simple syntax) 2.JavaScript can put dynamic text into an HTML page 3.JavaScript can react to events 4.JavaScript can read and write HTML elements 5.JavaScript can be used to validate data (validate form data) 6.JavaScript can be used to detect the visitor's browser 7.JavaScript can be used to create cookies

DOM (Document Object Model) In object-oriented programming we look at a program as a collection of interacting objects. – Objects have properties (facts about them) Length, width, – Objects have functions (things they can do) write(), shoot() In JavaScript the document is considered to be an object.

"dot" syntax Using Javascript we can access the properties of a document and change a document using special functions. When you see a dot (.) that implies ownership Examples: document.title document.images[1] document.write("Hi!")

First JavaScript Hello World! "); //--> /script> scripts\1_FirstJavaScript.html

events & event-listeners Javascript allows for interactivity. Specifically it tracks events: A mouse click A web page or an image loading Mousing over a hot spot on the web page Submitting an HTML form A keystroke And allows code to be attached to event-listeners: onLoad onUnload onMouseOver onMouseOut onSubmit

functions As you may have noticed event-listeners are a special type of built in functions. You can also create your own functions using the "function" keyword. All JavaScript code (like functions) should be put inside and tags. It is best to put as much of your JavaScript code as possible, in the head section of your document.

Body vs. Head function message() { alert("This alert box called by onload event"); } document.write("Message written by JavaScript"); 2_EventListeners

General Syntax 1.Scripts need to be in tags. 2.JavaScript statements 'should' end in a semicolon. 3.Large blocks of javascript 'should' be put in { } 4.Comments can be // or <* { document.write(" This is a heading "); document.write(" This is a paragraph. "); document.write(" This is another paragraph. "); // Single line comment /* Multi-line comment */ }

Declaring (Creating) Variables Variables are placeholders. You can create (or 'declare') them in JavaScript by using the "var" keyword. var x; var carname; You can also assign values to the variables when you declare them: var x=5; var carname="Volvo"; // Text requires quotes If you assign values to variables that have not yet been declared, the variables will automatically be declared. x=5; carname="Volvo"; See 3_Var_PromptBox3_Var_PromptBox

Math && Logic JavaScript supports the following operators Mathematical: +, -, *, /, %, ++, -- Logical: &&, ||, !,, etc... var x=10; var y=2; var z=x/y; Strings can be concatenated with the '+' sign. var txt1="What a very"; var txt2="nice day"; var txt3=txt1+" "+txt2; Note: If you add a number and a string, the result will be a string!

Selection (the 'if' statement) // Comments are VERY VERY important // If the time See file 4_Selection4_Selection

Repetition (loops) // This script shows the two common types of loops. // The for loop for (var counter = 1; counter <= 5; ++counter) { document.write(counter + " "); } // The while loop var i = true while (i == true) { i = window.confirm("Redisplay this dialog box?"); } See file 5_Repetition5_Repetition

Popup boxes As you have seen some of JavaScripts interactive abilities come from the use of pop-up boxes. There are 3 general kinds: alert("sometext"); confirm("sometext"); // returns "true" or "false") prompt("sometext","defaultvalue"); //returns what user enters as answer See 6_PopUps6_PopUps

Changing Page Properties Remember the DOM of JavaScript allows you to change the properties of a page… like the CSS sheet. function swapCss() { if(document.getElementById('css_sheet').href == 'default.css') { document.getElementById('css_sheet').href = 'alt.css'; } else { document.getElementById('css_sheet').href = 'default.css'; }

How Powerful is JavaScript? It is possible to do simple (and complex) animations (and even games) in JavaScript. You can create vector images in JavaScript (you will need to download a special library). You can load and swap bitmap (or jpeg, gif, etc.) images natively. Timing the image swaps can be done using the built in setTimeout method: t=setTimeout("javascript statement",milliseconds); Examples: SimpleAnimation1.html SimpleAnimation2.html SimpleAnimation3.html

Getting Help W3C JavaScript Tutorial: JavaScript Animations: animation-1/ JavaScript Games: