Simple Javascript Example

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

In our lesson today we will learn how to find the area of a building.
A really fairly simple guide to: mobile browser-based application development (part 1) Chris Greenhalgh G54UBI / Chris Greenhalgh
Javascript Document Object Model. How to use JavaScript  JavaScript can be embedded into your html pages in a couple of ways  in elements in both and.
CS 142 Lecture Notes: RubySlide 1 Basic Ruby Syntax sum = 0 i = 1 while i
CS 142 Lecture Notes: JavascriptSlide 1 Simple Javascript Example sum = 0; for (i = 1; i < 10; i++) { sum += i*i; }
AngularJS Controllers. A controller is a JavaScript object, created by a standard JavaScript object constructor. ng-controller directive defines an application.
1 CS101 Introduction to Computing Lecture 35 Mathematical Methods (Web Development Lecture 12)
1 CS101 Introduction to Computing Lecture 32 Event Handling (Web Development Lecture 11)
Web Programming and Security Lecture 1 Tamara Rezk.
Copyright © 2012 Pearson Education, Inc. Chapter 13: Introduction to Classes.
CS 215 Web Oriented Programming Review Dr. Orland Hoeber orland
DHTML: Dynamic HTML Internet Technology1. What is DHTML? A collection of enhancements to HTML ► To create dynamic and interactive websites Combination.
Lab 3: Actionscript User Interface Lab: GUI Lab Sep. 11 th, 2012.
This is the series In other words it is Consider the bars and how the represent the numbers in the sequence, and how the total sum of all.
Scripts Chapter Scripts Small programs used to add interactivity to your web pages The backbone of Dynamic HTML (DHTML) Most scripts are written.
Introduction to Client Side Scripting CS Client Side Scripting Client side means the Browser is interpreting the script Script is downloaded with.
Internet & World Wide Web How to Program, 5/e. © by Pearson Education, Inc. All Rights Reserved.
1 JavaScript Functions and Objects. 2 Objectives You will be able to Use JavaScript functions in JavaScript scripts. Get JavaScript functions executed.
JQuery Introduction © Copyright 2014, Fred McClurg All Rights Reserved.
Introduction to Programming and JavaScript. Programming.
“The world’s most misunderstood language has become the world’s most popular programming language” Akshay Arora
Javascript Overview. What is Javascript? May be one of the most popular programming languages ever Runs in the browser, not on the server All modern browsers.
CS 142 Lecture Notes: RubySlide 1 Basic Ruby Syntax sum = 0 i = 1 while i
JavaScript Events.
CS 142 Lecture Notes: JavascriptSlide 1 Simple Javascript Example sum = 0; for (i = 1; i < 10; i++) { sum += i*i; }
CS 142 Lecture Notes: JavascriptSlide 1 Simple Javascript Example sum = 0; for (i = 1; i < 10; i++) { sum += i*i; }
JavaScript and Ajax (JavaScript Environment) Week 6 Web site:
Introduction to JavaScript Events Instructor: Sergey Goldman 1.
Internet & World Wide Web How to Program, 5/e.  JavaScript events  allow scripts to respond to user interactions and modify the page accordingly  Events.
The Web Wizard’s Guide To JavaScript Chapter 4 Image Swapping.
Introduction to JavaScript
Build in Objects In JavaScript, almost "everything" is an object.
Classes and Class Members
© 2016, Mike Murach & Associates, Inc.
© 2016, Mike Murach & Associates, Inc.
Area of a Triangle.
Access Functions and Friend Functions
>> JavaScript: Location, Functions and Objects
Classes and Class Members
HTML & teh internets.
Simple Javascript Example
JavaScript Event Handling.
Intro to JavaScript CS 1150 Spring 2017.
CS 330 Class 5 Programming plan for today: Questions on homework
Inheritance and Prototypes
Google Maps: A Short How-to
JavaScript Events.
Basic Ruby Syntax sum = 0 i = 1 while i <= 10 do sum += i*i
CS 142 Lecture Notes: Events
DHTML Javascript Internet Technology.
Basic Ruby Syntax sum = 0 i = 1 while i <= 10 do sum += i*i
CS 142 Lecture Notes: Events
Substitution in string value
DHTML Javascript Internet Technology.
The Internet 12/8/11 JavaScript Review
Implementing Non-Static Features
The Web Wizard’s Guide To JavaScript
with a value of javascript:onclick=resizeWindow()
Extend Text Editor to Draw shapes
Today’s Objectives Week 12 Announcements ASP.NET
The Web Wizard’s Guide To JavaScript
Style properties in JavaScript
Simple Javascript Example
Tutorial 10: Programming with javascript
Introduction to Programming and JavaScript
The <script> Tag
CNIT 133 Interactive Web Pags – JavaScript and AJAX
Basic Ruby Syntax sum = 0 i = 1 while i <= 10 do sum += i*i
Presentation transcript:

Simple Javascript Example sum = 0; for (i = 1; i < 10; i++) { sum += i*i; } CS 142 Lecture Notes: Javascript

Factorial in Javascript function fac(x) { if (x <= 1) { return 1; } return x*fac(x-1); CS 142 Lecture Notes: Javascript

CS 142 Lecture Notes: Javascript Embedding Javascript External Javascript File <body> ... <script type="text/javascript" src="myCode.js" /> <script type="text/javascript"> //<![CDATA[ alert("Page is loading"); //]]> </script> <p onclick="alert(Hello, world!');"> Click here.</p> </body> Inline Code Event Handler CS 142 Lecture Notes: Javascript

CS 142 Lecture Notes: Javascript Method Example Object o = new Object(); o.count = 0; o.increment = function(inc) { if (inc == undefined) { inc = 1; } this.count += inc; return this.count; CS 142 Lecture Notes: Javascript

Functions Can Have Properties function plus1(value) { if (plus1.invocations == undefined) { plus1.invocations = 0;; } plus1.invocations++; return value+1; CS 142 Lecture Notes: Javascript

CS 142 Lecture Notes: Javascript Constructor function Rectangle(width, height) { this.width = width; this.height = height; } r = new Rectangle(26, 14); CS 142 Lecture Notes: Javascript

CS 142 Lecture Notes: Javascript Prototypes function Rectangle(width, height) { this.width = width; this.height = height; } Rectangle.prototype.area = function() { return this.width*this.height; r = new Rectangle(26, 14); a = r.area(); CS 142 Lecture Notes: Javascript

CS 142 Lecture Notes: Javascript