CS346 - Javascript 1, 21 Module 1 Introduction to JavaScript CS346.

Slides:



Advertisements
Similar presentations
Chapter 7 JavaScript: Introduction to Scripting. Outline Simple Programs Objects and Variables Obtaining User Input with prompt Dialogs – –Dynamic Welcome.
Advertisements

Introducing JavaScript
JavaScript FaaDoOEngineers.com FaaDoOEngineers.com.
Introduction to JavaScript
Introduction to PHP MIS 3501, Fall 2014 Jeremy Shafer
The Web Warrior Guide to Web Design Technologies
2440: 211 Interactive Web Programming JavaScript Fundamentals.
1 Outline 13.1Introduction 13.2A Simple Program: Printing a Line of Text in a Web Page 13.3Another JavaScript Program: Adding Integers 13.4Memory Concepts.
Tutorial 10 Programming with JavaScript
HTML Recall that HTML is static in that it describes how a page is to be displayed, but it doesn’t provide for interaction or animation. A page created.
Tutorial 1: Introduction to JavaScript JavaScript - Introductory.
Introduction To JavaScript What JavaScript Is: a general purpose scripting language that allows a static page to interact with users and respond to events.
Introduction to scripting
Javascript and the Web Whys and Hows of Javascript.
4.1 JavaScript Introduction
JavaScript: Control Structures September 27, 2005 Slides modified from Internet & World Wide Web: How to Program (3rd) edition. By Deitel, Deitel,
JavaScript, Fifth Edition Chapter 1 Introduction to JavaScript.
Introduction to JavaScript 11 Introduction to Programming the WWW I CMSC Winter 2004 Lecture 14.
CNIT 133 Interactive Web Pags – JavaScript and AJAX JavaScript Environment.
JavaScript 1. What is JavaScript? JavaScript allows web authors to create dynamic pages that react to user interaction. It is an Object-based because.
 2001 Prentice Hall, Inc. All rights reserved. 1 Chapter 7 - JavaScript: Introduction to Scripting Outline 7.1 Introduction 7.2 Simple Program: Printing.
CSC 330 E-Commerce Teacher Ahmed Mumtaz Mustehsan Ahmed Mumtaz Mustehsan GM-IT CIIT Islamabad GM-IT CIIT Islamabad CIIT Virtual Campus, CIIT COMSATS Institute.
SEG3210 DHTML Tutorial. DHTML DHTML is a combination of technologies used to create dynamic and interactive Web sites. –HTML - For creating text and image.
INTRODUCTION TO JAVASCRIPT AND DOM Internet Engineering Spring 2012.
1 JavaScript in Context. Server-Side Programming.
XP Tutorial 10New Perspectives on Creating Web Pages with HTML, XHTML, and XML 1 Working with JavaScript Creating a Programmable Web Page for North Pole.
TUTORIAL 10: PROGRAMMING WITH JAVASCRIPT Session 2: What is JavaScript?
Tutorial 10 Programming with JavaScript. XP Objectives Learn the history of JavaScript Create a script element Understand basic JavaScript syntax Write.
An Introduction to JavaScript Summarized from Chapter 6 of “Web Programming: Building Internet Applications”, 3 rd Edition.
 2003 Prentice Hall, Inc. All rights reserved. CHAPTER 3 JavaScript 1.
Introduction.  The scripting language most often used for client-side web development.  Influenced by many programming languages, easier for nonprogrammers.
JavaScript - A Web Script Language Fred Durao
JavaScript Tutorial 1 - Introduction to JavaScript WDMD 170 – UW Stevens Point 1 WDMD 170 Internet Languages eLesson: Introduction to JavaScript – A First.
XP Tutorial 10New Perspectives on HTML and XHTML, Comprehensive 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties Tutorial.
Dr. Qusai Abuein1 Internet & WWW How to program Chap.(6) JavaScript:Introduction to Scripting.
1 JavaScript
JavaScript Syntax, how to use it in a HTML document
Introduction to JavaScript CS101 Introduction to Computing.
Overview of Form and Javascript fundamentals. Brief matching exercise 1. This is the software that allows a user to access and view HTML documents 2.
1 A Balanced Introduction to Computer Science David Reed, Creighton University ©2005 Pearson Prentice Hall ISBN X Chapter 4 JavaScript and.
Sahar Mosleh California State University San MarcosPage 1 JavaScript Basic.
ECA 225 Applied Interactive Programming1 ECA 225 Applied Online Programming basics.
 2000 Deitel & Associates, Inc. All rights reserved. Outline 8.1Introduction 8.2A Simple Program: Printing a Line of Text in a Web Page 8.3Another JavaScript.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
JavaScript Introduction.  JavaScript is a scripting language  A scripting language is a lightweight programming language  A JavaScript can be inserted.
HTML JAVASCRIPT. CONTENTS Javascript Example NOSCRIPT Tag Advantages Summary Exercise.
4. Javascript M. Udin Harun Al Rasyid, S.Kom, Ph.D Lab Jaringan Komputer (C-307) Desain.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
Introduction into JavaScript Java 1 JavaScript JavaScript programs run from within an HTML document The statements that make up a program in an HTML.
1 JavaScript in Context. Server-Side Programming.
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.
Java Script About Java Script Document Object Model Incorporating JavaScript Adding JavaScript to HTML Embedding a Javascript External Scripts Javascript.
Tutorial 10 Programming with JavaScript. 2New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition Objectives Learn the history of JavaScript.
JavaScript. JavaScript Introduction JavaScript is the world's most popular programming language. It is the language for HTML and the web, for servers,
Chapter 1 Introduction to JavaScript JavaScript, Third Edition.
Javascript Intro Instructor: Shalen Malabon. Lesson Plan Core Javascript Syntax Types and Objects Functions DOM Event Handling Debugging Javascript Smarter.
Tutorial 10 Programming with JavaScript. 2New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition Objectives Learn the history of JavaScript.
1 CSC160 Chapter 1: Introduction to JavaScript Chapter 2: Placing JavaScript in an HTML File.
JavaScript and AJAX 2nd Edition Tutorial 1 Programming with JavaScript.
XP Tutorial 10New Perspectives on HTML, XHTML, and DHTML, Comprehensive 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties.
Module 1 Introduction to JavaScript
Introduction to Scripting
4. Javascript Pemrograman Web I Program Studi Teknik Informatika
14 A Brief Look at JavaScript and jQuery.
Introduction to JavaScript
WEB PROGRAMMING JavaScript.
Introduction to JavaScript
Tutorial 10: Programming with javascript
An Introduction to JavaScript
Introduction to JavaScript
Presentation transcript:

CS346 - Javascript 1, 21 Module 1 Introduction to JavaScript CS346

CS346 - Javascript 1, 22 JavaScript’s Role  HTML/CSS tells a browser how to render a document  JavaScript brings HTML to life by making Web pages dynamic  Use JavaScript to change the contents of a Web page after it has been rendered by a browser

CS346 - Javascript 1, 23 Popular Uses For JavaScript  Status Bar Messages  User Feedback  Popup Windows  Browser Detection  Random Images, Quotes  Display Current Date  Display Last Modified Date  Cookies  Rollovers  Banners  Redirection  Form Validation  Calculations  Reset Form

CS346 - Javascript 1, 24 The JavaScript Language  JavaScript is a scripting language executed by an interpreter from within a Web browser  Interpreter — translates programming code into executable format each time the program is run  Scripting engine — interpreter that is part of the Web browser

CS346 - Javascript 1, 25 The JavaScript Language  Introduced by Netscape and Sun in 1995 Originally called LiveScript  JavaScript is an object-oriented language  JavaScript is available in two formats: Client-side — available to HTML/XHTML pages displayed in Web browsers Server-side — proprietary and vendor- specific

CS346 - Javascript 1, 26 The Tag  … — contains statements that make up a JavaScript program in an HTML document Notifies browser that following commands need to be interpreted by a scripting engine  Attributes Language — specifies which scripting language and version is being used (OLD) type (NOW)

CS346 - Javascript 1, 27 Version Support JavaScript Version Browser Support Ns 2+, IE 3+, Op 3+ Ns 3+, IE 3.5+, Op 3.5+ Ns 4+, IE 4+, Op 3.5+ Ns 4.5+, IE 4+, Op 4+ Ns 5+, IE 4+, Op 5+ Ns 6+, IE 4+, Op 5+

CS346 - Javascript 1, 28 Objects & Methods  Object — programming code and data treated as an individual unit or component  Statements — individual lines of code Statements and are concluded with a semicolon  Methods — groups of related statements associated with an object  To execute, or call, an object’s methods, append the method to the object with a period

CS346 - Javascript 1, 29 Arguments  Argument — information that can be passed to a method The write( ) and writeIn( ) methods require a text string or variable as an argument Text string, or literal, is text that is contained within quotes document.write(“This is a test.”);  Case sensitivity

CS346 - Javascript 1, 210 Placing JavaScript Module 2

CS346 - Javascript 1, 211 JavaScript Placement  Browsers render tags in an HTML document in the order in which they are encountered  When there are multiple JavaScript code sections, each section is also executed in the order in which it appears  The order in which a browser executes JavaScript code also depends on if it is placed in the or section

CS346 - Javascript 1, 212 JavaScript Source Files  Often incorporated directly into an HTML document  Can also be saved in an external file called a source file with file extension.js May use a combination of embedded JavaScript and source files in your web pages  The src attribute accepts a text string to specify the location of a JS source file Should only be declared once, in the  Source files cannot include HTML tags

CS346 - Javascript 1, 213 JavaScript Source Files  Reasons for using source files instead of adding code to HTML: HTML document will be neater JavaScript code sharable among multiple HTML documents JavaScript source files are not as likely to be “borrowed”

CS346 - Javascript 1, 214 JavaScript Comments  Comments are various types of remarks that you place in code that do not render notes to yourself instructions for future programmers  JavaScript is included in HTML comments ( ) not interpreted by browsers that do not support JavaScript

CS346 - Javascript 1, 215 JavaScript Comments  One-line comments — add two slashes // before the text document.write("This is cool!"); // this is a comment  Block comments — add /* to the first line in the block and */ to the last line of the block /* My script writes some text into my document! All of this text is ignored by the browser. */

CS346 - Javascript 1, 216 Hello World Script < ! - - document.writeln(“Hello World”); document.writeln(“This line is printed below.”); // - - >

CS346 - Javascript 1, 217 Output of the Hello World Script

CS346 - Javascript 1, 218 Examples  JavaScript examples JS-1 Examples  2-1Precedence.htm 2-1Precedence.htm  2-2MultipleJavascriptCalls.htm 2-2MultipleJavascriptCalls.htm  2-3ExternalJS.htm 2-3ExternalJS.htm  2-4ExternalJS.htm 2-4ExternalJS.htm

CS346 - Javascript 1, 219 Summary JS-1, JS-2  A client-side scripting language  Script (code) is downloaded by UA  UA interprets (runs) the script  Script can generate XHTML  Script can change element attributes, including style  Script can interact w/ user

CS346 - Javascript 1, 220 Hello, world <!-- HIDE // Hide script from lame UA's document.writeln( " Hello, world "); // UNHIDE -->

CS346 - Javascript 1, 221 Sequence of events  Browser interprets script which generates output (XHTML)  Browser renders the generated XHTML

CS346 - Javascript 1, 222 write and writeln  write and writeln are methods of document object  Both take a string argument String literals are enclosed in double or single quotes Use \" and \' to embed quotes in a string literal Use \n \t \\ as in Java, C++  writeln puts a newline into generated XHTML  write does not put in a newline

CS346 - Javascript 1, 223 String concatenation: + operator <!-- document.write(" The" + " content" + " of this paragraph is" + " the \"concatenation\"" + " of several strings."); document.write(" "); // -->

CS346 - Javascript 1, 224 JavaScript code format  JavaScript statements may contain whitespace (line breaks, tabs, spaces) for readability  Except in string literals  JavaScript is case sensitive  Comments: //… and /* … */