4.1 JavaScript Introduction

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

Chapter 08: Adding Adding Interactivity Interactivity With With Behaviors Behaviors By Bill Bennett Associate Professor MSJC CIS MVC.
JavaScript FaaDoOEngineers.com FaaDoOEngineers.com.
Java Script Session1 INTRODUCTION.
Introduction to JavaScript
JavaScript Objects - DOM CST 200 JavaScript. Objectives Introduce JavaScript objects Introduce Document Object Model Introduce window object Introduce.
1 CSC 551: Web Programming Spring 2004 client-side programming with JavaScript  scripts vs. programs  JavaScript vs. JScript vs. VBScript  common tasks.
The Web Warrior Guide to Web Design Technologies
Outline IS400: Development of Business Applications on the Internet Fall 2004 Instructor: Dr. Boris Jukic JavaScript: Introduction to Scripting.
Tutorial 10 Programming with JavaScript
2012 •••••••••••••••••••••••••••••••••• Summer WorkShop Mostafa Badr
Introduction to JavaScript. Aim To enable you to write you first JavaScript.
Introduction to scripting
JavaScript: Control Structures September 27, 2005 Slides modified from Internet & World Wide Web: How to Program (3rd) edition. By Deitel, Deitel,
CS346 - Javascript 1, 21 Module 1 Introduction to JavaScript CS346.
JavaScript, Fifth Edition Chapter 1 Introduction to JavaScript.
Chapter 5 Java Script And Forms JavaScript, Third Edition.
 2003 Prentice Hall, Inc. All rights reserved. CHAPTER 3 JavaScript 1.
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.
Lesson 19. JavaScript errors Since JavaScript is an interpreted language, syntax errors will usually cause the script to fail. Both browsers will provide.
JavaScript Tabriz university Its September 1995.
 2001 Prentice Hall, Inc. All rights reserved. 1 Chapter 7 - JavaScript: Introduction to Scripting Outline 7.1 Introduction 7.2 Simple Program: Printing.
Client Scripting1 Internet Systems Design. Client Scripting2 n “A scripting language is a programming language that is used to manipulate, customize,
Lesson13. JavaScript JavaScript is an interpreted language, designed to function within a web browser. It can also be used on the server.
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. XP Objectives Learn the history of JavaScript Create a script element Understand basic JavaScript syntax Write.
 2003 Prentice Hall, Inc. All rights reserved. CHAPTER 3 JavaScript 1.
Chapter 5: Windows and Frames
JavaScript - A Web Script Language Fred Durao
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.
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.
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.
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.
1 Chapter 3 – JavaScript Outline Introduction Flowcharts Control Structures if Selection Structure if/else Selection Structure while Repetition Structure.
JavaScript Introduction. Slide 2 Lecture Overview JavaScript background The purpose of JavaScript A first JavaScript example Introduction to getElementById.
 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.
 Web pages originally static  Page is delivered exactly as stored on server  Same information displayed for all users, from all contexts  Dynamic.
Chapter 7 - JavaScript: Introduction to Scripting Outline 7.1 Introduction 7.2 Simple Program: Printing a Line of Text in a Web Page 7.3 Another JavaScript.
1 Javascript CS , Spring What is Javascript ? Browser scripting language  Dynamic page creation  Interactive  Embedded into HTML pages.
Tutorial 10 Programming with JavaScript. 2New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition Objectives Learn the history of JavaScript.
Lesson 30: JavaScript and DHTML Fundamentals. Objectives Define and contrast client-side and server-side technologies used to create dynamic content for.
Tutorial 10 Programming with JavaScript. 2New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition Objectives Learn the history of JavaScript.
Beginning JavaScript 4 th Edition. Chapter 1 Introduction to JavaScript and the Web.
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.
1 CSC160 Chapter 1: Introduction to JavaScript Chapter 2: Placing JavaScript in an HTML File.
CGS 3066: Web Programming and Design Spring 2016 Introduction to JavaScript.
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.
REEM ALMOTIRI Information Technology Department Majmaah University.
XP Tutorial 10New Perspectives on HTML, XHTML, and DHTML, Comprehensive 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties.
Web Programming Java Script-Introduction. What is Javascript? JavaScript is a scripting language using for the Web. JavaScript is a programming language.
 2001 Prentice Hall, Inc. All rights reserved. Outline 1 JavaScript.
Introduction to.
Module 1 Introduction to JavaScript
Introduction to Scripting
JavaScript Introduction
JavaScript an introduction.
WEB PROGRAMMING JavaScript.
Tutorial 10 Programming with JavaScript
JavaScript: Introduction to Scripting
Presentation transcript:

4.1 JavaScript Introduction

Scripting Languages Distinguishing features not compiled interpreted not strongly typed subprograms can be added at run time text of program code can be directly executed programs can be constructed at run time

Scripting Languages (cont.) Typical additional features associative arrays regular expressions good string processing objects, classes, inheritance functionality can be added at run time

JavaScript Scripting language Adds functionality to web pages associative arrays DOM (Document Object Model) is directly accessible Adds functionality to web pages Runs on the client side interpreter is embedded in the browser Makes it possible to change XHTML elements and their properties Dynamic HTML (DHTML) JavaScript = ECMA-Script Syntax like C

JavaScript vs. Java JavaScript is quite different from Java similar syntax because they both descend from C Java is strongly typed Java is compiled (into byte code) actually hybrid because byte code is mostly interpreted Java has strong Object Oriented foundation in JavaScript, OO was an afterthought now is getting better The name was primarily a marketing decision Sun and Netscape against Microsoft We will primarily learn JavaScript in terms of its differences to Java We assume that you know Java well!

Browser Problems Before users can run JavaScript scripts, they may need to change the browser’s security settings By default Internet Explorer (IE) disables JavaScript FireFox (FF) enables JavaScript Browsers render web pages differently DOM programming is cumbersome each vendor implements DOM differently legacy of browser wars

Enabling JavaScript in Internet Explorer 7 JavaScript in IE Enabling JavaScript in Internet Explorer 7

<script> Element either contains scripts an entire program can be placed there or contains reference to external scripts file this is the preferred way! type attribute specifies the scripting language used text/javascript for JavaScript there is also VBScript language Microsoft's effort to dominate the market src attribute URL of a file with an external script standard file extension .js for JavaScript source files s

JavaScript in a Web Page Typically, <script> is placed within the <head> element of the XHTML document the contents inside <head> is interpreted first this is the preferred way But <script> elements can be placed in the <body> element, too they are executed in the order in which they appear in the XHTML document Script fragments occur in the attributes of other elements e.g. in elements of a form (<input> button), <div> element to define the response to events typically just a function call

Script Inside <script> Some browsers do not support <script> we must put the script within an XHTML comment <script type = "text/javascript"> <!–- … //--> </script> the JavaScript comment // is needed so that --> isn't interpreted as JavaScript statement otherwise the script will appear as web page text

Writing a Web Page The DOM document object represents the XHTML document of the web page currently displayed in the browser document.write() or document.writeln() insert XHTML code into the XHTML document once the page is rendered, document.write() replaces the entire page this allows us to specify (portions of) a web page via scripting! alert() displays a dialog with message passed a the argument string prompt() and an input field where the user can type a text

Example <html xmlns = "http://www.w3.org/1999/xhtml"><head> <title>Welcome</title> <link rel="stylesheet" href="sample.css" /> <script language="JavaScript" src="sample.js"></script> </head><body> <script type = "text/javascript"> <!— var title = "Welcome"; var text = "415 is fun!"; document.writeln("<h1>"+title+"</h1>"); document.writeln("<p>"+text+"</p>"); alert (title+"\n"+text); //--> </script> </body></html>