An Introduction to JavaScript

Slides:



Advertisements
Similar presentations
Introducing JavaScript
Advertisements

Essentials for Design JavaScript Level One Michael Brooks
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
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.
Working with JavaScript. 2 Objectives Introducing JavaScript Inserting JavaScript into a Web Page File Writing Output to the Web Page Working with Variables.
Tutorial 10 Programming with JavaScript
XP 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties Tutorial 10.
XP Tutorial 1 New Perspectives on JavaScript, Comprehensive1 Introducing JavaScript Hiding Addresses from Spammers.
Chapter 11 ASP.NET JavaScript, Third Edition. 2 Objectives Learn about client/server architecture Study server-side scripting Create ASP.NET applications.
Tutorial 1: Introduction to JavaScript JavaScript - Introductory.
1 CS428 Web Engineering Lecture 18 Introduction (PHP - I)
Introducing HTML & XHTML:. Goals  Understand hyperlinking  Understand how tags are formed and used.  Understand HTML as a markup language  Understand.
Introduction to scripting
INTRODUCTION TO WEB DATABASE PROGRAMMING
Creating a Basic Web Page
Copyright © cs-tutorial.com. Introduction to Web Development In 1990 and 1991,Tim Berners-Lee created the World Wide Web at the European Laboratory for.
CS346 - Javascript 1, 21 Module 1 Introduction to JavaScript CS346.
JavaScript, Fifth Edition Chapter 1 Introduction to JavaScript.
Introduction to JavaScript 11 Introduction to Programming the WWW I CMSC Winter 2004 Lecture 14.
Client Scripting1 Internet Systems Design. Client Scripting2 n “A scripting language is a programming language that is used to manipulate, customize,
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. XP Objectives Learn the history of JavaScript Create a script element Understand basic JavaScript syntax Write.
Tutorial 10 Programming with JavaScript
Done by: Hanadi Muhsen1 Tutorial 1.  Learn the history of JavaScript  Create a script element  Write text to a Web page with JavaScript  Understand.
Introduction.  The scripting language most often used for client-side web development.  Influenced by many programming languages, easier for nonprogrammers.
JavaScript Tutorial 1 - Introduction to JavaScript WDMD 170 – UW Stevens Point 1 WDMD 170 Internet Languages eLesson: Introduction to JavaScript – A First.
JavaScript Tutorial 1 - Introduction to JavaScript1 Tutorial 1 Introduction to JavaScript Section A – Programming, HTML, and JavaScript.
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.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
Client-side & Server-side Scripting ©Richard L. Goldman August 5, 2003 Requires PowerPoint 2002 or later for full functionality.
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.
JavaScript, Sixth Edition Chapter 1 Introduction to JavaScript.
Tutorial 10 Programming with JavaScript. 2New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition Objectives Learn the history of JavaScript.
Chapter 1 Introduction to JavaScript JavaScript, Third Edition.
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.
Chapter 1 Introduction to JavaScript.  Study the history of the World Wide Web  Work with well-formed Web pages  Learn about Web development  Learn.
1 Chapter 1 INTRODUCTION TO WEB. 2 Objectives In this chapter, you will: Become familiar with the architecture of the World Wide Web Learn about communication.
Module 1 Introduction to JavaScript
Chapter 6 JavaScript: Introduction to Scripting
Tutorial 10 Programming with JavaScript
Introduction and Principles
Introduction to Scripting
4. Javascript Pemrograman Web I Program Studi Teknik Informatika
PHP / MySQL Introduction
14 A Brief Look at JavaScript and jQuery.
JavaScript Introduction
DHTML Javascript Internet Technology.
About the Presentations
Introducing HTML & XHTML:
Chapter 27 WWW and HTTP.
WEB PROGRAMMING JavaScript.
DHTML Javascript Internet Technology.
Tutorial Developing a Basic Web Page
Tutorial 10 Programming with JavaScript
CIS 133 mashup Javascript, jQuery and XML
JavaScript CS 4640 Programming Languages for Web Applications
Tutorial 10: Programming with javascript
JavaScript is a scripting language designed for Web pages by Netscape.
CIS 136 Building Mobile Apps
JavaScript CS 4640 Programming Languages for Web Applications
Presentation transcript:

An Introduction to JavaScript

Introduction to Web Development Web page design (web design) Visual design and creation of documents appearing on the World Wide Web Web page authoring (web authoring) Creation and assembly of the tags, attributes, data making up a web page Web development or web programming Design of software applications for a website Web browsers contain commands to view underlying HTML code Only view to improve skills

Understanding Client/Server Architecture Two-tier system Client and server Server or back end Usually a database: client requests information Client or front end Responsible for user interface Gathers information from user Submits information to server Receives, formats, presents results returned from the server

Understanding Client/Server Architecture (cont’d.) A two-tier client/server system Web built on a two-tier client/server system Requests and responses through which a web browser and web server communicate happen with HTTP

Understanding Client/Server Architecture (cont’d.) A three-tier client/server system Three-tier, multitier, client/server system Client tier Processing tier Data storage tier

JavaScript and Client-Side Scripting Static web pages Cannot change after browser renders them HTML produces static documents JavaScript Allows web page authors to develop interactive web pages and sites Client-side scripting language: runs on local browser Scripting engine executes scripting language code Scripting host Web browser containing a scripting engine

JavaScript and Client-Side Scripting (cont’d.) JavaScript history First introduced in Navigator (LiveScript) Navigator 2.0: name changed to JavaScript 1.0 Microsoft released Internet Explorer 4.0 version of JavaScript (Jscript) ECMAScript International, standardized version of JavaScript

JavaScript and Client-Side Scripting (cont’d.) Limitations of JavaScript Cannot be used outside the web browser Cannot run system commands or execute programs on a client

Understanding Server-Side Scripting Scripting language executed from a web server Popular languages: PHP, ASP.NET, Python, Ruby Can develop interactive web sites to communicate with a database Server-side scripting language limitations Cannot access or manipulate a web browser Cannot run on a client tier

Understanding Server-Side Scripting (cont’d.) How a web server processes a server-side script

Should You Use Client-Side or Server-Side Scripting? General rule of thumb Allow client to handle user interface processing and light processing (data validation) Have the web server perform intensive calculations and data storage Important to perform as much processing as possible on the client

Adding JavaScript to Your Web Pages

Using the <script> Element Scripts JavaScript programs contained within a Web page A JavaScript program can either be placed directly in a Web page file or saved in an external text file <script> element Tells the browser that the scripting engine must interpret the commands it contains <script type="mime-type"> Tells the browser which scripting language and the type attribute indicates which version of the scripting language being used

Using the <script> Element <script type="mime-type"> script statements; </script> Each statement inside the script tags is a single line that indicates an action for the browser to take The semicolon notifies the browser that it has reached the end of the statement HTML5 eliminates the need for the type attribute <script>

Understanding JavaScript Objects any item—from the browser window itself to a document displayed in the browser to an element displayed within the document Programming code and data Treated as an individual unit or component Procedures Individual statements used in a computer program grouped into logical units Used to perform specific tasks Methods a process by which JavaScript manipulates or acts upon the properties of an object Procedures associated with an object

Understanding JavaScript Objects (cont’d.) Property Piece of data associated with an object Assign value to a property using an equal sign Argument Information that must be provided to a method Passing arguments Providing an argument for a method

Using the write() and writeln() Methods Document object Represents content of a browser’s window To write text to a Web page, use the following JavaScript commands: document.write(“text”); or document.writeln(“text”)’ where text is the content to be written to the page.

Using the write() and writeln() Methods document.write(“text”); or document.writeln(“text”)’ The document.write() and document.writeln() methods are identical, except that the document.writeln() method preserves any line breaks in the text string Both methods require a text string as an argument Text string (aka literal string) Text contained within double or single quotation marks

Using the write() and writeln() Methods (cont’d.) Output of a script that uses the writeln() method of the Document object

Case Sensitivity in JavaScript JavaScript is case sensitive Ignores most occurrences of extra white space Do not break a statement into several lines Within JavaScript code: Object names must always be all lowercase

Structuring JavaScript Code

Including a <script> Element for Each Code Section Can include as many script sections as desired Must include a <script> element for each section Example code below

Placing JavaScript in the Document Head or Document Body <script> element placement varies Can place in the document head or document body Statements in a script Rendered in the order in which they appear in the document General rule Place as much JavaScript code as possible in the document head Important if code performs behind-the-scenes tasks required by script sections located in the document body

Creating a JavaScript Source File External file containing JavaScript code Usually designated by the .js file extension Can legally have any extension Contains only JavaScript statements No <script> element and no XHTML elements Use the src attribute of the <script> element Advantages Neater code; code sharing; ability to hide JavaScript code from incompatible browsers Can use embedded JavaScript code and JavaScript source files combination

Validating Web Pages If HTML is buggy, then there's a good chance your Javascript or jQuery code will fail Use an HTML Validating parser Checks for a well formed HTML Web page Validation Process of verifying a well-formed document and checking the elements in your document Validating services found online W3C Markup Validation Service: http://validator.w3.org

Writing Valid JavaScript Code JavaScript statements contain symbols Prevents HTML document from being well formed Web pages will not validate when they contain script Two options to resolve validation issue Move code into a source file Keep JavaScript code within the document Enclose code within a <script> element within a CDATA