Client Side Programming with JavaScript Why use client side programming? Web sides built on CGI programs can rapidly become overly complicated to maintain,

Slides:



Advertisements
Similar presentations
The Web Warrior Guide to Web Design Technologies
Advertisements

JavaScript- Introduction. What it is and what it does? What it is? It is NOT Java It is NOT Server-side programming Users can see code It is a client-side.
Introduction to Web Site Development Steven Emory Department of Computer Science California State University, Los Angeles Lecture 8: JavaScript I.
Computer Science 103 Chapter 4 Advanced JavaScript.
JavaScript Lesson 1 TBE 540. Prerequisites  Before beginning this lesson, the learner must be able to… Create a basic web page using a text editor and/or.
Introduction to JavaScript for Python Programmers
Introduction To JavaScript What JavaScript Is: a general purpose scripting language that allows a static page to interact with users and respond to events.
Inline, Internal, and External FIle
Introduction to JavaScript. Aim To enable you to write you first JavaScript.
Introduction to scripting
Web Programming Material From Greenlaw/Hepp, In-line/On-line: Fundamentals of the Internet and the World Wide Web 1 Introduction The JavaScript Programming.
1 Events Lect 8. 2 Event-driven Pages one popular feature of the Web is its interactive nature e.g., you click on buttons to make windows appear e.g.,
Javascript and the Web Whys and Hows of Javascript.
Lecture Note 3: ASP Syntax.  ASP Syntax  ASP Syntax ASP Code is Browser-Independent. You cannot view the ASP source code by selecting "View source"
JavaScript Defined DOM (Document Object Model) General Syntax Body vs. Head Variables Math & Logic Selection Functions & Events Loops Animation Getting.
Applied Software for Internet Engineers by Dr Zhanfang ZHAO Room: T409 Tel: Study hours: 150hrs, 24 hrs lecture/Tutorials,
Event Handlers CS101 Introduction to Computing. Learning Goals Learn about event handlers Determine how events are useful in JavaScript Discover where.
1 JavaScript E-Commerce Prof. Sheizaf Rafaeli
Bridges To Computing General Information: This document was created for use in the "Bridges to Computing" project of Brooklyn College. You are invited.
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.
DHTML: Dynamic HTML Internet Technology1. What is DHTML? A collection of enhancements to HTML ► To create dynamic and interactive websites Combination.
CSS Class 7 Add JavaScript to your page Add event handlers Validate a form Open a new window Hide and show elements Swap images Debug JavaScript.
Client Scripting1 Internet Systems Design. Client Scripting2 n “A scripting language is a programming language that is used to manipulate, customize,
What is Java Script? An extension to HTML. An extension to HTML. Allows authors to incorporate some functionality in their web pages. (without using CGI.
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.
Programming with Java © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 1 McGraw-Hill/Irwin Chapter 14 JavaScript.
Extending HTML CPSC 120 Principles of Computer Science April 9, 2012.
Client-Side Scripting JavaScript.  produced by Netscape for use within HTML Web pages.  built into all the major modern browsers. properties  lightweight,
Introduction.  The scripting language most often used for client-side web development.  Influenced by many programming languages, easier for nonprogrammers.
JavaScript - A Web Script Language Fred Durao
JavaScript Adding active content to websites. Goals Understand structure of JavaScript Understand rules of coding Add active content to WebPages Add functions.
JavaScript Syntax, how to use it in a HTML document
Introduction to JavaScript CS101 Introduction to Computing.
JavaScript Scripting language What is Scripting ? A scripting language, script language, or extension language is a programming language.
Introduction to Programming JScript Six Scripting functions Discuss functions Password Example.
Sahar Mosleh California State University San MarcosPage 1 JavaScript Basic.
ECA 225 Applied Interactive Programming1 ECA 225 Applied Online Programming basics.
Event JavaScript's interaction with HTML is handled through events that occur when the user or browser manipulates a page. When the page loads, that is.
IS2802 Introduction to Multimedia Applications for Business Lecture 3: JavaScript and Functions Rob Gleasure
1 CSC160 Chapter 7: Events and Event Handlers. 2 Outline Event and event handlers onClick event handler onMouseOver event handler onMouseOut event handler.
WDMD 170 – UW Stevens Point 1 WDMD 170 Internet Languages eLesson: Variables, Functions and Events (NON-Audio version) © Dr. David C. Gibbs WDMD.
JavaScript Defined DOM (Document Object Model) General Syntax Body vs. Head Variables Math & Logic Selection Functions & Events Loops Animation Getting.
CIS 3.5 Lecture 2.3 "Introduction to JavaScript".
1) PHP – Personal Home Page Scripting Language 2) JavaScript.
Web Programming Overview. Introduction HTML is limited - it cannot manipulate data How Web pages are extended (include): –Java: an object-oriented programming.
Introduction to JavaScript MIS 3502, Spring 2016 Jeremy Shafer Department of MIS Fox School of Business Temple University 2/2/2016.
1 CSC160 Chapter 1: Introduction to JavaScript Chapter 2: Placing JavaScript in an HTML File.
Javascript Basic Concepts Presentation By: Er. Sunny Chanday Lecturer CSE/IT RBIENT.
Web Programming Java Script-Introduction. What is Javascript? JavaScript is a scripting language using for the Web. JavaScript is a programming language.
Tarik Booker CS 120 California State University, Los Angeles.
Introduction to.
Module 1 Introduction to JavaScript
Week 4: Introduction to Javascript
JavaScript is a programming language designed for Web pages.
Donna J. Kain, Clarkson University
Barb Ericson Georgia Institute of Technology May 2006
DHTML Javascript Internet Technology.
A second look at JavaScript
Your 1st Programming Assignment
WEB PROGRAMMING JavaScript.
Introduction to JavaScript for Python Programmers
Events Comp 205 Fall 2017.
DHTML Javascript Internet Technology.
Tutorial 10 Programming with JavaScript
Tutorial 10: Programming with javascript
JavaScript Basics What is JavaScript?
JavaScript is a scripting language designed for Web pages by Netscape.
Introduction to Programming and JavaScript
Presentation transcript:

Client Side Programming with JavaScript Why use client side programming? Web sides built on CGI programs can rapidly become overly complicated to maintain, and there is also the problem of response time. One example is the dynamic graphing. It is nearly impossible to perform with consistency because a GIF file must be created and move from the server to client for each version of the graph. Why JavaScript is introduced? JavaScript, just as other script language such as Tcl/Tk, used inside Web Browser is really intended to solve specific types of problem, primarily the creation of richer and more interactive graphical user interfaces (GUIs).

With JavaScript you can: –Create swapping images on your Webpage. –Do calculations without having to resort to a CGI script. –Let the form elements to influence each other on the fly. Outcomes: –How to integrate the JavaScript code into your HTML document. –Basic Syntax: Variables, if-then branching –How to make your Web pages react to users' actions using link events to do a basic image swap.

First Example (js1.html) JavaScript Example // put up an alert box, to show how they work alert("Soon, I will rebuild my browser!");

Key things to notice to this example JavaScript usually goes between the tag and the tag. Like HTML, JavaScript is just text that can be typed into a word processor. The beginning of a bit of JavaScript begins with Right now, you don't really have to put the language="JavaScript" element in there because JavaScript is the default script language for all browsers. However, this could change, so it's a good idea to include the language element. Everything between // and the end of a line is a comment and will be ignored. alert("Soon, I will rebuild my browser!"); calls up a simple dialog box with the words JavaScripts end with the tag.

Hiding JavaScript blah blah blah <!-- hide this stuff from other browsers YOUR SCRIPT HERE // end the hiding comment --> etc., etc., etc.

Example using variables (js2.html) JavaScript Variable Example <!-- hide me // load up some variables var secs_per_min = 60; var mins_per_hour = 60; var hours_per_day = 24; var days_per_year = 365; // do some calculations var secs_per_day = secs_per_min * mins_per_hour * hours_per_day; var secs_per_year = secs_per_day * days_per_year; // end hiding -->

Things should notice in header part The first time you use a variable, you should declare it with the word “var”. Variable names are case-sensitive. You can give a variable a value when you declare it, or you can wait until later Statements end with a semicolon.

Example using variables (js2.html)(Continued) How does the monkey stay so fit? <!-- hide me // here's how to use JavaScript to write out HTML document.writeln(" The monkey dances "); document.writeln(secs_per_year); document.writeln(" seconds per year. "); // end hiding -->

Things about the body part of this example document.writeln() (as in "write line") Writes whatever's between the parentheses to a Web page. Characters inside quotes are printed; characters not inside quotes are considered variables. What JavaScript goes in the head of a page and what goes in the body? Usually it doesn't matter, but it's a good idea to put most of your JavaScript in the head of a page. This is because the head gets read before the body, so any variables that appear in the body (like secs_per_min) will already have been declared in the head by the time they're needed. If for some reason secs_per_min were defined after JavaScript tried to do the document.writeln(secs_per_min) command, you'd get a JavaScript error.

If-then Branching What "if-then" statements do is allow your program to behave very differently depending on what a user inputs. Here's the basic form of an if-then statement: if (some condition is true) { do something; do something; do something; } The important part of this structure are: –It starts with the word "if" (if must be lowercase). –There is a condition in parentheses that is either true or false. –There is a set of statements that should be executed if the condition is true. These statements go between curly brackets.

Example for if – then Branching var monkey_love = prompt("Do you love the monkey?","Type yes or no"); if (monkey_love == "yes") { alert("Welcome! I'm so glad you came! Please, read on!"); }

Link Events Whenever a user clicks on a link, or moves her cursor over one, JavaScript is sent a link event. One link event is called onClick, and it gets sent whenever someone clicks on a link. Another link event is called onMouseOver. This one gets sent when someone moves the cursor over the link. Please notice, there are no tags. That's because anything that appears in the quotes of an onClick or an onMouseOver is automatically interpreted as JavaScript. note that there's a # sign between the quotes in the href="#". This makes it so the browser doesn't try to load another Web page when you click on the link. If you put in the href instead of the #, the browser would run the JavaScript in the onClick and the load up this here SBU site.

Example for link events Link Event Example Link Events Click on me! Mouse over me!

Image Swapping Image Swapping Example Image Swapping #This is just like a standard tag except this one has been given a # name: the_image. #This is where the image swap happens change change