<script type="text/javascript"> script commands </script>

Similar documents
Tutorial 10: Programming with JavaScript

Working with JavaScript

JavaScript Introduction

Lecture 14. Introduction to JavaScript. Mr. Mubashir Ali Lecturer (Dept. of Computer Science)

Programming language components

JAVASCRIPT BASICS. JavaScript String Functions. Here is the basic condition you have to follow. If you start a string with

CSC Web Programming. Introduction to JavaScript

JavaScript: The Basics

Command-driven, event-driven, and web-based software

JavaScript CS 4640 Programming Languages for Web Applications

Web Programming and Design. MPT Junior Cycle Tutor: Tamara Demonstrators: Aaron, Marion, Hugh

What is Java Script? Writing to The HTML Document. What Can JavaScript do? CMPT 165: Java Script

JavaScript CS 4640 Programming Languages for Web Applications

CHAPTER 6 JAVASCRIPT PART 1

INFS 2150 Introduction to Web Development and e-commerce Technology. Programming with JavaScript

Objectives. Introduction to JavaScript. Introduction to JavaScript INFS Peter Y. Wu, RMU 1

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

Java Programming Fundamentals - Day Instructor: Jason Yoon Website:

Software. Programming Languages. Types of Software. Types of Languages. Types of Programming. Software does something

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

JavaScript s role on the Web

Program Design Phase. Algorithm Design - Mathematical. Algorithm Design - Sequence. Verify Algorithm Y = MX + B

CSCE 120: Learning To Code

People = End Users & Programmers. The Web Browser Application. Program Design Phase. Algorithm Design -Mathematical Y = MX + B

PHP 1. Introduction Temasek Polytechnic

welcome to BOILERCAMP HOW TO WEB DEV

Princess Nourah bint Abdulrahman University. Computer Sciences Department

PHP and MySQL for Dynamic Web Sites. Intro Ed Crowley

Web Application Development (WAD) V th Sem BBAITM(Unit-1) By: Binit Patel

CISC 1600 Lecture 2.4 Introduction to JavaScript

CGS 3066: Spring 2015 JavaScript Reference

COMS 469: Interactive Media II

COSC 122 Computer Fluency. Programming Basics. Dr. Ramon Lawrence University of British Columbia Okanagan

Lotus Using JavaScript in IBM Lotus Domino 7 Applications.

Exercise 1: Basic HTML and JavaScript

JavaScript: Introduction, Types

CITS1231 Web Technologies. JavaScript

Server side basics CS380

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

Variables and Typing

5. JavaScript Basics

JAVASCRIPT AND JQUERY: AN INTRODUCTION (WEB PROGRAMMING, X452.1)

PHP. Interactive Web Systems

CS1046 Lab 4. Timing: This lab should take you 85 to 130 minutes. Objectives: By the end of this lab you should be able to:

Session 6. JavaScript Part 1. Reading

Exercise 1 Using Boolean variables, incorporating JavaScript code into your HTML webpage and using the document object

3 The Building Blocks: Data Types, Literals, and Variables

PHP: The Basics CISC 282. October 18, Approach Thus Far

EXERCISE: Introduction to client side JavaScript

Q1. What is JavaScript?

Chapter 3 - Simple JavaScript - Programming Basics. Lesson 1 - JavaScript: What is it and what does it look like?

Controlled Assessment Task. Question 1 - Describe how this HTML code produces the form displayed in the browser.

Web Programming and Design. MPT Junior Cycle Tutor: Tamara Demonstrators: Aaron, Marion, Hugh

Such JavaScript Very Wow

CS312: Programming Languages. Lecture 21: JavaScript

Introduction to Programming Using Java (98-388)

Introduction to JavaScript

Javascript. Daniel Zappala. CS 360 Internet Programming Brigham Young University

Why Discuss JavaScript? CS312: Programming Languages. Lecture 21: JavaScript. JavaScript Target. What s a Scripting Language?

This tutorial will teach you about operators. Operators are symbols that are used to represent an actions used in programming.

Session 16. JavaScript Part 1. Reading

Programming In Java Prof. Debasis Samanta Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur

URLs and web servers. Server side basics. URLs and web servers (cont.) URLs and web servers (cont.) Usually when you type a URL in your browser:

Manju Muralidharan Priya. CS4PM Web Aesthetics and Development WEEK 11

Unveiling the Basics of CSS and how it relates to the DataFlex Web Framework

Getting started with Java

2 rd class Department of Programming. OOP with Java Programming

User Interaction: jquery

JAVASCRIPT - OPERATORS

PIC 40A. Lecture 10: JS: Wrapper objects, Input and Output, Control structures, random numbers. Copyright 2011 Jukka Virtanen UCLA 1 04/24/17

SEEM4570 System Design and Implementation Lecture 03 JavaScript

Course Syllabus. Course Title. Who should attend? Course Description. PHP ( Level 1 (

c122mar413.notebook March 06, 2013

EVENT-DRIVEN PROGRAMMING

COMP519 Practical 5 JavaScript (1)

JavaScript by Vetri. Creating a Programmable Web Page

Pace University. Fundamental Concepts of CS121 1

Outcomes Week 2 Overview Describe the inputs, activities, and outputs of each step in the software development life cycle. Describe arithmetic, relati

Client vs Server Scripting

JavaScript Functions, Objects and Array

COMS 469: Interactive Media II

Python Input, output and variables. Lecture 23 COMPSCI111/111G SS 2018

Language Reference Manual

Continuing Education Course #192 Web-Based Programming For Engineers - Part 3

Produced by. App Development & Modeling. BSc in Applied Computing. Eamonn de Leastar

Intro to Programming. Unit 7. What is Programming? What is Programming? Intro to Programming

Exceptions in Java

Lecture 2. The variable 'x' can store integers, characters, string, float, boolean.

<form>. input elements. </form>

JAVASCRIPT AND JQUERY: AN INTRODUCTION (WEB PROGRAMMING, X452.1)

2D Game design Intro to Html 5

CS2900 Introductory Programming with Python and C++ Kevin Squire LtCol Joel Young Fall 2007

CS 251 Intermediate Programming Methods and Classes

CS 251 Intermediate Programming Methods and More

First Java Program - Output to the Screen

Session 7. JavaScript Part 2. W3C DOM Reading and Reference

A PROGRAM IS A SEQUENCE of instructions that a computer can execute to

Programming. Syntax and Semantics

HTML 5 and CSS 3, Illustrated Complete. Unit L: Programming Web Pages with JavaScript

Introduction to JavaScript Programming Test Bank Chapter 1 with XML and PHP

Transcription:

JavaScript

Java vs. JavaScript JavaScript is a subset of Java JavaScript is simpler and less powerful than Java JavaScript programs can be embedded within HTML files; Java code must be separate Java code runs in an applet window, whereas JavaScript code can run directly within a web browser

Inserting JavaScript To insert a JavaScript program in a webpage, using the script element with the following syntax: script commands JavaScript code can be placed in the head or the body (or both).

Elements of JavaScript A JavaScript program consists of a series of statements. Each statement (command) is a single line that indicates an action for the browser to take. An object is anything - from the browser window itself to an element displayed within the document. A method is a process by which JavaScript manipulates or affects the properties of an object. A variable is a named item in a program that stores a data value. Variables must be declared before they are used.

JavaScript syntax JavaScript is case sensitive and ignores most occurrences of extra white space. You shouldn t break a statement into several lines. Comments in JavaScript are inserted with // comment

JavaScript syntax To declare a JavaScript variable and set its initial value (you don t always need an initial value), use var variable = value; where variable is the name assigned to the variable and value is its initial value. The data types in JavaScript are Numeric (any number), Text Strings (any group of text characters), Boolean (true/false), and Null (no value).

JavaScript syntax A function is a collection of commands that performs an action or returns a value. Each function has a name which identifies it. Parameters are values used by the function. FunctionName(parameter values) A function is executed only when called by another JavaScript command. For a function to return a value, it must include a return statement.

Function syntax function FunctionName(parameters) { JavaScript commands return value; }

Concatenation and arithmetic The + symbol can be used to concatenate strings. In other words, given two strings a and b, a + b gives a new string made up of string a followed by string b. +, -, *, / can also be used as standard arithmetic symbols to perform some calculation in a script, for example within a function.

Writing output to an HTML file To write text to a webpage with JavaScript, use the method document.write("text"); where text is stuff to be written to the webpage. text could even contain HTML commands, which will be interpreted by the browser as actual HTML code.

Very simple function function hello() { document.write("hello world"); }

Calling the function hello();

Writing HTML code with JavaScript function hello() { document.write("<h3 style='color:blue'>hello world</h3>"); }

Function with parameters function join(word1,word2) { document.write("i think " + word1 + " tastes good with " + word2 + "."); } join("peanut butter","jelly");

Function with variable function join(word1,word2) { var total = "I think " + word1 + " tastes good with " + word2 + "."; document.write("<p style='font-size:1.5em'>"+total+"</p>"); document.write("<p style='font-size:1em'>"+total+"</p>"); document.write("<p style='font-size:0.5em'>"+total+"</p>"); } join("peanut butter","jelly");

Simple arithmetic function product(number1,number2,number3) { var result = number1*number2/number3; document.write(result); } product(15,7,5);

Anti-spam function function email(username,server) { var link = username + "@" + server; document.write("<a href='mailto:" + link + "'>"); document.write(link); document.write("</a>"); } email("brimkov", "fredonia.edu")