Introduction to JavaScript

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.
1 COMM 1213 H1 COMP 4923 X1 JavaScript 1 (Readings: Ch. 10, 11 Knuckles)
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
Information Technology Center Hany Abdelwahab Computer Specialist.
XP Tutorial 1 New Perspectives on JavaScript, Comprehensive1 Introducing JavaScript Hiding Addresses from Spammers.
CIS101 Introduction to Computing Week 09 Spring 2004.
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.
Scripting Languages.
 2003 Prentice Hall, Inc. All rights reserved. CHAPTER 3 JavaScript 1.
Ku-Yaw Chang Assistant Professor, Department of Computer Science and Information Engineering Da-Yeh University.
Internet Mark-up Languages CO32036 Part Lecture: Elementary JavaScript.
THE BIG PICTURE. How does JavaScript interact with the browser?
DHTML: Dynamic HTML Internet Technology1. What is DHTML? A collection of enhancements to HTML ► To create dynamic and interactive websites Combination.
The Web Wizard’s Guide To JavaScript Chapter 6 Working with Dates and Times.
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.
Client Scripting1 Internet Systems Design. Client Scripting2 n “A scripting language is a programming language that is used to manipulate, customize,
INTRODUCTION TO JAVASCRIPT AND DOM Internet Engineering Spring 2012.
Tutorial 10 Programming with JavaScript
 2003 Prentice Hall, Inc. All rights reserved. CHAPTER 3 JavaScript 1.
DHTML AND JAVASCRIPT Genetic Computer School LESSON 5 INTRODUCTION JAVASCRIPT G H E F.
JavaScript Syntax, how to use it in a HTML document
Introduction to JavaScript CS101 Introduction to Computing.
XP Tutorial 8 Adding Interactivity with ActionScript.
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.
1 Server versus Client-Side Programming Server-SideClient-Side.
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.
Javascript JavaScript is what is called a client-side scripting language:  a programming language that runs inside an Internet browser (a browser is also.
CGS 3066: Web Programming and Design Spring 2016 Introduction to JavaScript.
JavaScript: A short introduction Joseph Lee Created by Joseph Lee.
Javascript Javascript The JavaScript Programming Language – Scripting Languages Executed by an interpreter contained within.
JavaScript Part 1 Introduction to scripting The ‘alert’ function.
Module 1 Introduction to JavaScript
Using DHTML to Enhance Web Pages
CIIT-Human Computer Interaction-CSC456-Fall-2015-Mr
Chapter 6 JavaScript: Introduction to Scripting
Tutorial 10 Programming with JavaScript
Chapter 2 Client/Server Applications
Project 9 Creating Pop-up Windows, Adding Scrolling Messages, and Validating Forms.
Section 17.1 Section 17.2 Add an audio file using HTML
* Lecture # 7 Instructor: Rida Noor Department of Computer Science
PHP / MySQL Introduction
JavaScript.
14 A Brief Look at JavaScript and jQuery.
Chapter 7 - JavaScript: Introduction to Scripting
Objectives Insert a script element Write JavaScript comments
DHTML Javascript Internet Technology.
JavaScript: Introduction to Scripting
WEB PROGRAMMING JavaScript.
Integrating JavaScript and HTML
DHTML Javascript Internet Technology.
JavaScript.
Introduction to JavaScript
Tutorial 10 Programming with JavaScript
Tutorial 10: Programming with javascript
JavaScript: Introduction to Scripting
Chapter 7 - JavaScript: Introduction to Scripting
Chapter 7 - JavaScript: Introduction to Scripting
The Web Wizard’s Guide To JavaScript
Introduction to JavaScript
Intro to Programming (in JavaScript)
Chapter 7 - JavaScript: Introduction to Scripting
Presentation transcript:

Introduction to JavaScript JavaScript is the most popular programming language today. Largely because of the popularity of the Web and that it is the only language available in the browsers. JavaScript is a scripting language The browser receives JavaScript “code” as text and then “interprets” it into “machine code” that the computer understands.

JavaScript Client Server Browser Web Server HTML File HTML File Internet Server Browser URL Web Server HTML File HTML File Image File Image File Script Scripts

JavaScript in HTML <script> var x=12; var y=2; var z=x+y; alert(z); </script> Put these lines into a file named “test.html” and open it in a browser. You can right click and “View source” to see the browser has loaded your code.

Math Calculations var AngleInDegrees=12; var DistanceInMeters=100; var AngleInRadians=AngleInDegrees/180*Math.PI; var X=Math.sin(AngleInRadians)*DistanceInMeters; var Y=Math.cos(AngleInRadians)*DistanceInMeters; alert("X="+X+", Y="+Y); Put these lines into a file named “test.html” and open it in a browser. You can right click and “View source” to see the browser has loaded your code.

Strings You can create and manipulate “strings” of characters in JavaScript. Each letter, number, or symbol is one character. Strings combine characters together into phrases of text.

Strings in JavaScript <script> var String1=“hi“; var String 2=“class”; var String3=String1+String2; alert(String3); </script> Put these lines into a file named “test.html” and open it in a browser. You can right click and “View source” to see the browser has loaded your code.

Strings Character 3 H i c l a s 1 2 3 4 5 6 7 Indexes

Strings Once you define a string, you can: Get it’s length “Subset” it (slice out a part of it) Find phrases within it Concatenate it with other strings

Types Variables in JavaScript are defined by a “type”. There are other types but the most common are: Number String The type determines what you can do with it: 1+1 = 2 “1” + “1” = “11”

Type Conversion If you have a number in a string “123” “123.456” You can convert it to a number: parseInt() parseFloat()

Functions Functions “encapsulate” code so you can easily reuse the code.

Functions function GetXFromAngleAndDistance(AngleInDegrees,DistanceInMeters) { var AngleInRadians=AngleInDegrees/180*Math.PI; var X=Math.sin(AngleInRadians)*DistanceInMeters; return(X); } function GetYFromAngleAndDistance(AngleInDegrees,DistanceInMeters) var Y=Math.cos(AngleInRadians)*DistanceInMeters; return(Y); var Angle=10; var Distance=100; var X=GetXFromAngleAndDistance(Angle,Distance); var Y=GetYFromAngleAndDistance(Angle,Distance);

Basic JavaScript For this class, all you need is: Calculations with numbers Text manipulation Converting text to numbers Functions

With JavaScript you can: Do almost everything you can in other modern programming languages: Create variables Do math, date and string functions Create “if” statements, “for” loops, “while” loops, and functions Create Object Oriented Designs

You can also Access and modify the contents of your web pages Put up error dialogs Make it look like you’re putting up windows with controls like buttons, popup menus, lists, etc. Display dynamic maps Interact with the user in many other ways

JavaScript cannot Access the local computers disk drive, network (other than it’s original server), printer, and other resources Launch another program Add viruses to your computer

Extra slides

JavaScript in HTML <script> var ThePrefix=“Arcata is at “; var TheCoordinateString=“40.8665° N, 124.0828° W” TheFinalString= ThePrefix+TheCoordinateString </script> Put these lines into a file named “test.html” and open it in a browser. You can right click and “View source” to see the browser has loaded your code.