COMS W3101: SCRIPTING LANGUAGES: JAVASCRIPT (FALL 2017)

Similar documents
COMS W3101: SCRIPTING LANGUAGES: JAVASCRIPT (FALL 2018)

LECTURE-2. Functions review HTML Forms. Arrays Exceptions Events. CS3101: Scripting Languages: Javascript Ramana Isukapalli

CSC Web Programming. Introduction to JavaScript

Web Site Development with HTML/JavaScrip

introduction to XHTML

HTML. Mohammed Alhessi M.Sc. Geomatics Engineering. Internet GIS Technologies كلية اآلداب - قسم الجغرافيا نظم المعلومات الجغرافية

A HTML document has two sections 1) HEAD section and 2) BODY section A HTML file is saved with.html or.htm extension

HTML HTML/XHTML HTML / XHTML HTML HTML: XHTML: (extensible HTML) Loose syntax Few syntactic rules: not enforced by HTML processors.

Chapter 1 Getting Started with HTML 5 1. Chapter 2 Introduction to New Elements in HTML 5 21

CSC 121 Computers and Scientific Thinking

Lecture : 3. Practical : 2. Course Credit. Tutorial : 0. Total : 5. Course Learning Outcomes

Creating A Web Page. Computer Concepts I and II. Sue Norris

UNIT -II. Language-History and Versions Introduction JavaScript in Perspective-

Chapter 2:- Introduction to XHTML. Compiled By:- Sanjay Patel Assistant Professor, SVBIT.

As we design and build out our HTML pages, there are some basics that we may follow for each page, site, and application.

recall: a Web page is a text document that contains additional formatting information in the HyperText Markup Language (HTML)

c122jan2714.notebook January 27, 2014

COPYRIGHTED MATERIAL. Contents. Chapter 1: Creating Structured Documents 1

This document provides a concise, introductory lesson in HTML formatting.

Advanced Web Programming C2. Basic Web Technologies

Html basics Course Outline

Programmazione Web a.a. 2017/2018 HTML5

Module 2 (III): XHTML

A Balanced Introduction to Computer Science, 3/E

Mobile Site Development

HTML Summary. All of the following are containers. Structure. Italics Bold. Line Break. Horizontal Rule. Non-break (hard) space.

JavaScript: Introduction, Types

INTRODUCTION TO HTML5! HTML5 Page Structure!

1. The basic building block of an HTML document is called a(n) a. tag. b. element. c. attribute. d. container. Answer: b Page 5

HTMLnotesS15.notebook. January 25, 2015

Announcements. Paper due this Wednesday

Hyper Text Markup Language HTML: A Tutorial

COPYRIGHTED MATERIAL. Contents. Introduction. Chapter 1: Structuring Documents for the Web 1

The internet is a worldwide collection of networks that link millions of computers. These links allow the computers to share and send data.

Scripting for Multimedia LECTURE 1: INTRODUCING HTML5

Introduction to HTML. SSE 3200 Web-based Services. Michigan Technological University Nilufer Onder

SEEM4570 System Design and Implementation Lecture 03 JavaScript

Introduction to the Internet and World Wide Web p. 1 The Evolution of the Internet p. 2 The Internet, Intranets, and Extranets p. 3 The Evolution of

BEFORE CLASS. If you haven t already installed the Firebug extension for Firefox, download it now from

PIC 40A. Midterm 1 Review

Student, Perfect Midterm Exam March 24, 2006 Exam ID: 3193 CS-081/Vickery Page 1 of 5

Understanding this structure is pretty straightforward, but nonetheless crucial to working with HTML, CSS, and JavaScript.

HTML Overview formerly a Quick Review

Tizen Web UI Technologies (Tizen Ver. 2.3)

Introduction to JavaScript p. 1 JavaScript Myths p. 2 Versions of JavaScript p. 2 Client-Side JavaScript p. 3 JavaScript in Other Contexts p.

Bridges To Computing

Certified HTML5 Developer VS-1029

Syllabus - July to Sept

MPT Web Design. Week 1: Introduction to HTML and Web Design

Web Programming and Design. MPT Senior Cycle Tutor: Tamara Week 1

HTML. Mendel Rosenblum. CS142 Lecture Notes - HTML

Document Object Model. Overview

Final Exam Study Guide

Web Development & Design Foundations with XHTML. Chapter 2 Key Concepts

Introduction to Web Technologies

Web development using PHP & MySQL with HTML5, CSS, JavaScript

Motivation (WWW) Markup Languages (defined). 7/15/2012. CISC1600-SummerII2012-Raphael-lec2 1. Agenda

Year 8 Computing Science End of Term 3 Revision Guide

The first sample. What is JavaScript?

Web Development and HTML. Shan-Hung Wu CS, NTHU

1.264 Lecture 12. HTML Introduction to FrontPage

CISC 1600 Lecture 2.4 Introduction to JavaScript

INTRODUCTION TO WEB USING HTML What is HTML?

Index. CSS directive, # (octothorpe), intrapage links, 26

CS 350 COMPUTER/HUMAN INTERACTION. Lecture 6

Lecture 3: The Basics of JavaScript. Background. Needs for Programming Capability. Origin of JavaScript. Using Client-side JavaScript

What is a web site? Web editors Introduction to HTML (Hyper Text Markup Language)

UI Course HTML: (Html, CSS, JavaScript, JQuery, Bootstrap, AngularJS) Introduction. The World Wide Web (WWW) and history of HTML

LING 408/508: Computational Techniques for Linguists. Lecture 14

A network is a group of two or more computers that are connected to share resources and information.

Web Programming/Scripting: JavaScript

CHAPTER 2 MARKUP LANGUAGES: XHTML 1.0

HTML: Parsing Library

HTML and CSS COURSE SYLLABUS

Web Design and Application Development

CSC Web Programming. Introduction to HTML

HyperText Markup Language (HTML)

HTML, XHTML, and CSS. Sixth Edition. Chapter 1. Introduction to HTML, XHTML, and

1/6/ :28 AM Approved New Course (First Version) CS 50A Course Outline as of Fall 2014

A Brief Introduction to HTML

This course is designed for web developers that want to learn HTML5, CSS3, JavaScript and jquery.

CIS 228 (Spring, 2012) Final, 5/17/12

Week 1 - Overview of HTML and Introduction to JavaScript

HTML TAG SUMMARY HTML REFERENCE 18 TAG/ATTRIBUTE DESCRIPTION PAGE REFERENCES TAG/ATTRIBUTE DESCRIPTION PAGE REFERENCES MOST TAGS

Revision for Grade 7 ASP in Unit :1&2 Design & Technology Subject

11. HTML5 and Future Web Application

('cre Learning that works for Utah STRANDS AND STANDARDS WEB DEVELOPMENT 1

NEW WEBMASTER HTML & CSS FOR BEGINNERS COURSE SYNOPSIS

The [HTML] Element p. 61 The [HEAD] Element p. 62 The [TITLE] Element p. 63 The [BODY] Element p. 66 HTML Elements p. 66 Core Attributes p.

COMPSCI 120 Fall 2017 Review Questions for Midterm #2 Professor William T. Verts

The course also includes an overview of some of the most popular frameworks that you will most likely encounter in your real work environments.

Web Development & Design Foundations with HTML5

PIC 40A. Lecture 4b: New elements in HTML5. Copyright 2011 Jukka Virtanen UCLA 1 04/09/14

Mobile MOUSe WEB SITE DESIGN ONLINE COURSE OUTLINE

INDIAN SCHOOL DARSAIT FIRST TERM EXAM- MAY 2017 MULTIMEDIA AND WEB TECHNOLOGY (067) SAMPLE PAPER Class: XI Max.Marks: 70

JavaScript By: A. Mousavi & P. Broomhead SERG, School of Engineering Design, Brunel University, UK

Unit 5 Web Publishing Systems Page 1 of 13 Part 4 HTML Part 4

A.A. 2008/09. Why introduce JavaScript. G. Cecchetti Internet Software Technologies

Project 3 Web Security Part 1. Outline

Create web pages in HTML with a text editor, following the rules of XHTML syntax and using appropriate HTML tags Create a web page that includes

Transcription:

COMS W3101: SCRIPTING LANGUAGES: JAVASCRIPT (FALL 2017) RAMANA ISUKAPALLI RAMANA@CS.COLUMBIA.EDU 1

LECTURE-1 Course overview See http://www.cs.columbia.edu/~ramana Overview of HTML Formatting, headings, images, colors, tables, forms, etc. XHTML difference with HTML DHTML What is it? Why is it needed Javascript Overview, what is it, why is it needed, etc. How does it fit with HTML 2

PREREQUISITES A good background in at least one programming language is recommended. Ability to learn quickly. 3

OVERVIEW OF HTML HTTP: Communication protocol between Any web server (e.g., www.cnn.com) and Browswer (e.g., firefox, IE, Opera, etc.) HTML Hyper-Text Markup Language Format in which web data is stored. Web Browser HTTP Web Server 4

HTML CONTD. Format in which a web server stores the content. Transferred over to the client (using HTTP). Hypertext stores data of many formatssimple text with different fonts, sizes, colors, paragraphs, etc. Audio, video, image files, etc. Uses markup tags, e.g., <h1> Heading </h1> Can arrange data in tables, bullets, web links, forms, etc. HTML details HTML details http://www.w3schools.com/html/default.asp http://www.w3.org/tr/html4/ 5

A TYPICAL HTML PAGE <html> <!-- Beginning of the HTML page --> <head> <!--Typically has page title, useful for search engines --> <title> Sample Web page </title> <-- Page title --> </head> <body> <-- Body of the web page, has main content--> Content </body> </html> <-- End of the HTML page --> 6

HTML TAGS Headings <h1>, <h2>, <h3> Anchor <a> Table <table> Table row <tr> Table cell <td> No support for scripts <noscript> n n n n n Form <form> Image <img> Lists <li> Ordered list <ol> Unordered list -- <ul> n No support for frames <noframes> n n These tags are used to format a web page content A complete list of tags can be found at http://w3schools.com/tags/default.asp 7

XHTML XHTML EXtensible HyperText Markup Language Combines HTML with strict syntax of XML Almost identical to HTML XHTML is a stricter and cleaner version of HTML. XHTML is HTML defined as an XML application. XHTML consists of DOCTYPE declaration head Body 8

XHTML RULES XHTML elements must be Properly nested e.g., <head> <title>. </title> </head> Always closed e.g., <body>.. </body> In lowercase XHTML documents must have one root element XHTML attribute names must be in lower case values must be quoted e.g., <table width= 100% minimization is forbidden <input checked="checked" /> instead of <input checked> 9

DHTML DYNAMIC HTML Web requirements have became more demanding. Not just static requirements. Check validity of input given on a web page. Ability to manipulate data dynamically based on User input Already available data. Provide animation Highlight a text area with a different color. Change behavior of images on mouse clicks, focus, etc. Solution: DHTML Ability to change HTML content dynamically. 10

DHTML Components of HTML to support dynamic nature of content: CSS cascading style sheets To present the data HTML Domain Object Model (DOM) Ability to access and change different portions (e.g., head, body, input, etc.) of a web page. Javascript Run scripts for various purposes Running scripts, creating cookies, animation, etc. This course is about Javascript. We will cover basic HTML first, before discussing Javascript. 11

JAVASCRIPT OVERVIEW This course is concerned with client side JS Executes on client (browser) Scripting NOT compile/link. Helps provide dynamic nature of HTML pages. Included as part of HTML pages as Regular code (viewable by user) A file present in some location. NOTE: Javascript is NOT the same as JAVA 12

A SIMPLE JAVASCRIPT PROGRAM <html> <head> <title> A simple Javascript program </title> </head> <body> <script> document.write ( A Simple Javascript program ); </script> </body> </html> 13

JAVASCRIPT CODE Javascript code in HTML Javascript code can be placed in <head> part of HTML file Code is NOT executed unless called in <body> part of the file. <body> part of HTML file executed along with the rest of body part. Outside HTML file, location is specified. Executed when called in <body> 14

WAYS OF DEFINING JAVASCRIPT CODE. First: <head> <script type= text/javascript > function foo( ) // defined here </script> </head> <body> <script type= text/javascript > foo( ) // called here </script> </body> Second: <head> </head> <body> <script> function foo( ) // defined here {.. } foo( ) // Called here </script> </body> 15

WAYS OF DEFINING JAVASCRIPT CODE, CONTD. Third: <head> // Any general location, that can be accessed. <script src= http://cnn.com/foo.js"> </script> </head> <body> <script> // Javascript code called here. </script> </body> 16

JAVASCRIPT DATA TYPES Basic data types number: E.g., 2, 3, 4, 10.6, 3.1415, 1.2e8, 3.2e-10 string: E.g., abc, Bob Doe boolean: true, false Complex data types Objects Functions 17

JAVASCRIPT BASIC TYPES Not a strongly typed language x = 5; x = string is perfectly acceptable. Case sensitive. A variable has a var prefix. var x = 5 is same as just, x = 5. Re-declaration is possible Possible to mix and match while printing document.write (6 + 10 + xyz ) prints 16xyz document.write ( xyz + 6 + 10) prints xyz610 18

JAVASCRIPT OBJECTS var person = { firstname:"john", lastname:"doe", email: JohnDoe@gmail.com, age: 38 }; To access values, use object.propertyname or object[ propertyname] Example person[firstname] person[ firstname ] 19

JAVASCRIPT FINDING DATA TYPES Useful operator to find data types: typeof typeof(10) à number typeof(3.1415) à number typeof( abcd ) à string name = Bob ; typeof(name) à string typeof(true) à boolean value = false; typeof(value) à false var x = 10; typeof(x) à number typeof(x) à undefined. typeof(person) à object 20

JAVASCRIPT OPERATORS Arithmetic operators: Usual ones +, -, *, /, %, ++, -- Assignment operators =, +=, -=, *=, /=, % = String operators: + (concatenation operator) Comparison operators: ==,!=, ===, >, <, >=, <= Logical operators &&,,! Conditional operator variable = (condition)? value1: value2 21

JAVASCRIPT CONTROL STATEMENTS if statement: Example: if (cond1) <code-1> else if (cond2) <code-2> else <code-3> if (x %2 == 0) document.write( x is a multiple of 2 ); else if (x%3 == 0) document.write( x is a multiple of 3 ); else document.write( x is not a multiple of 2 or 3); 22

JAVASCRIPT CONTROL STATEMENTS for statement: for (i = 0; i < n; i++) { // code } Example: var x; var mycars = new Array(); mycars[0] = "Saab"; mycars[1] = "Volvo"; mycars[2] = "BMW"; for (x in mycars) { document.write (mycars[x] + "<br /> ); } 23

JAVASCRIPT CONTROL STATEMENTS CONTD. do statement do { <code> } while (cond); while statement: while (cond) { <code> } switch statement: switch (n) { case n1: <code> break; default: <code> } 24

JAVASCRIPT POPUP BOXES Alert box alert ( alert text ); Confirm box confirm ( confirm some text ); Prompt box prompt ( prompt text, default value ) 25

JAVASCRIPT FUNCTIONS Syntax function <functionname> (params) { // code } Note: Parameters do NOT have variable type. 1. Recall: Function definition can be in <head> part of HTML file. <body> portion of HTML file An external file. 2. return value of the function is optional. 26

FUNCTIONS EXAMPLE1 <html> <head> <title> Example of a simple function </title> <script type="text/javascript"> function factorial (input) { product = 1; for (i=1; i <= input; i++) product *= i; document.write ("factorial of i " + product); } </script> </head> <body> <h1> Example of a simple function </h1> <script type="text/javascript"> factorial (9); </script> </body> </html> 27

FUNCTIONS EXAMPLE2 <html> <head> <title>browser Information example</title> <script type="text/javascript"> function BrowserInfoFn( ) { var browser = navigator.appname; var version = navigator.appversion; var ver = parsefloat (version); document.write ("Broswer: " + browser + " version: + version + " ver: " + ver + "<br />"); } </script> </head> <body> <h1>browser Information example</h1> <script type="text/javascript"> BrowserInfoFn( ); </script> <hr> </body> </html> 28