OVERVIEW OF CLIENT-SIDE SCRIPTING

Slides:



Advertisements
Similar presentations
JavaScript I. JavaScript is an object oriented programming language used to add interactivity to web pages. Different from Java, even though bears some.
Advertisements

Java Script Session1 INTRODUCTION.
Georgia Institute of Technology JavaScript part 2 Barb Ericson Georgia Institute of Technology May 2006.
1 The Information School of the University of Washington Oct 30fit review Programming Review INFO/CSE 100, Fall 2006 Fluency in Information Technology.
1 HCI 201 JavaScript - Part 1. 2 Static web pages l Static pages: what we have worked with so far l HTML tags tell the browser what to do with the content.
1 Outline 13.1Introduction 13.2A Simple Program: Printing a Line of Text in a Web Page 13.3Another JavaScript Program: Adding Integers 13.4Memory Concepts.
Working with JavaScript. 2 Objectives Introducing JavaScript Inserting JavaScript into a Web Page File Writing Output to the Web Page Working with Variables.
Information Technology Center Hany Abdelwahab Computer Specialist.
Comparing Numeric Values If Val(Text1.Text) = MaxPrice Then (Is the current numeric value stored in the Text property of Text1 equal to the value stored.
Computer Science 103 Chapter 4 Advanced JavaScript.
Javascript II Expressions and Data Types. 2 JavaScript Review programs executed by the web browser programs embedded in a web page using the script element.
CS 299 – Web Programming and Design Overview of JavaScript and DOM Instructor: Dr. Fang (Daisy) Tang.
2012 •••••••••••••••••••••••••••••••••• Summer WorkShop Mostafa Badr
Introduction to JavaScript for Python Programmers
Introduction to scripting
Web Programming – Java Script Association of Computing Activities Computer Science and Engineering Indian Institute of Technology Kanpur.
XP Tutorial 14 New Perspectives on HTML, XHTML, and DHTML, Comprehensive 1 Working with Forms and Regular Expressions Validating a Web Form with JavaScript.
JavaScript Form Validation
WEB DESIGN AND PROGRAMMING Introduction to Javascript.
Review and Practice for Final exam. Final exam Date: December 20, 3:15 – 5:15pm Format: Two parts: First part: multiple-choice questions (15 questions.
JavaScript JavaScript is a scripting language that is most commonly used to add client- side programming to a web page. Some of the things it is used for.
Chapter 5 Java Script And Forms JavaScript, Third Edition.
JavaScript Part 1.
Chapter 3 : Processing on the Front End JavaScript Technically its name is ECMA-262, which refers to the international standard which defines it. The standard.
UFCEWT-20-3 Advanced Topics in Web Development Lecture 4 : JavaScript, Browsers & the HTML DOM-API.
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,
Javascript. Outline Introduction Fundamental of JavaScript Javascript events management DOM and Dynamic HTML (DHTML)
Chapter 3: Data Types and Operators JavaScript - Introductory.
Data types, Literals (constants) and Variables Data types specify what kind of data, such as numbers and characters, can be stored and manipulated within.
Chapter 4 JavaScript and Dynamic Web pages. Objectives Static Web pages Dynamic Web pages JavaScript Variables Assignments. JavaScript Functions –(prompt(“”,””)
CMPS 211 JavaScript Topic 1 JavaScript Syntax. 2Outline Goals and Objectives Goals and Objectives Chapter Headlines Chapter Headlines Introduction Introduction.
1 JavaScript in Context. Server-Side Programming.
XP Tutorial 10New Perspectives on Creating Web Pages with HTML, XHTML, and XML 1 Working with JavaScript Creating a Programmable Web Page for North Pole.
Using Client-Side Scripts to Enhance Web Applications 1.
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,
20-753: Fundamentals of Web Programming 1 Lecture 12: Javascript I Fundamentals of Web Programming Lecture 12: Introduction to Javascript.
JavaScript, jQuery, and Mashups Incorporating JavaScript, jQuery, and other Mashups into existing pages.
JS Basics 1 Lecture JavaScript - Basics. JS Basics 2 What is JavaScript JavaScript is a “simple”, interpreted, programming language with elementary object-
HTML Form Widgets. Review: HTML Forms HTML forms are used to create web pages that accept user input Forms allow the user to communicate information back.
Input & Output Functions JavaScript is special from other languages because it can accept input and produce output on the basis of that input in the same.
JavaScript - Basic Concepts Prepared and Presented by Hienvinh Nguyen, Afshin Tiraie.
Scott Marino MSMIS Summer Session Web Site Design and Authoring Session 8 Scott Marino.
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.
Fluency with Information Technology INFO100 and CSE100 Katherine Deibel Katherine Deibel, Fluency in Information Technology1.
JavaScript, Fourth Edition
Introduction To JavaScript. Putting it Together (page 11) All javascript must go in-between the script tags. All javascript must go in-between the script.
JavaScript Challenges Answers for challenges
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
Chapter 4 Java Script - Part1. 2 Outlines Introduction to Java Script Variables, Operators and Functions Conditional statements JavaScript Objects Forms.
JavaScript Events Java 4 Understanding Events Events add interactivity between the web page and the user You can think of an event as a trigger that.
JQUERY AND AJAX
JavaScript Events. Understanding Events Events add interactivity between the web page and the user Events add interactivity between the web page and the.
Strings Robin Burke IT 130. Outline Objects Strings methods properties Basic methods Form validation.
XP Tutorial 10New Perspectives on HTML, XHTML, and DHTML, Comprehensive 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties.
1 Agenda  Unit 7: Introduction to Programming Using JavaScript T. Jumana Abu Shmais – AOU - Riyadh.
JavaScript Tutorial First lecture 19/2/2016. Javascript is a dynamic computer programming language. It is lightweight and most commonly used as a part.
Client-side (JavaScript) Validation. Associating a function with a click event – Part 1 Use the input tag’s onclick attribute to associate a function.
© 2010 Robert K. Moniot1 Chapter 6 Introduction to JavaScript.
>> Introduction to JavaScript
Web Programming– UFCFB Lecture 17
WEB PROGRAMMING JavaScript.
T. Jumana Abu Shmais – AOU - Riyadh
Functions, Regular expressions and Events
Web Programming– UFCFB Lecture 13
Barb Ericson Georgia Institute of Technology May 2006
Web Programming and Design
Presentation transcript:

OVERVIEW OF CLIENT-SIDE SCRIPTING

Welcome to client-side scripting Make stuff happen on the user's computer without ever hitting the server Who cares? – Usability: It "feels good" for the user – Aesthetics: It looks impressive – Performance: It's faster than hitting the server – Scalability: It conserves server resources

Hyperlinks – your best non-script option Click me Another link Clicking a link causes the entire page to refresh, forcing a network request… very slow and ugly.

Examples of some scripting alert("hello world!"); Just mix some script tags into the HTML. The alert function just shows a textual popup.

Writing out HTML document.write(" HELLO, Mr. Smith!!! "); // text on next line is small so that PowerPoint doesn’t wrap line document.write(" "); The document.write function writes HTML to the page right when it is first loaded.

Variables var x = confirm("do you like it?"); document.write(" "+x+" "); The confirm function prompts the user and returns a Boolean. There is no static type system. The variable x will get treated as a Boolean at runtime when it is assigned. Its evaluated value will be converted to a string for concatenation with " " and " ".

Conditionals and comparisons var i = 40; if (i == 41-1 && i !== '40') document.write('looks nice'); else document.write('kinda weird'); Concatenation with a string yields a string. Comparison with == or != allows for type conversion, though. Comparison with === or !== requires an exact equality.

Loops for (var x = 0; x < 100; x++) document.write(x+" "); Much as in C or Java.

Arrays var myarray = ["A", "B", "C", "D"]; document.write(myarray[1]+"ob is the man!"); Each array object is indexed from 0 and has a.length property that indicates its number of elements.

Associative arrays var myobj = {name:"Jimmy", age:54}; alert(myobj.name+" is " + myobj.age); You can nest objects if you like. For example, myobj = {name:"Jimmy", age:54, son:{name:"Sam", age:20}};

Checking if an array entry is set var myobj = {name:"Jimmy", age:54}; alert("has son: "+(myobj.son ? "yes" : "no")); Missing values are equal to null. And null values are converted to a false Boolean in conditionals.

Functions function piEstimate() { return 3.14; } alert("PI is approximately "+ piEstimate()); Seems simple, right? Not so much. There's a whole lecture coming up about how fancy and sometimes confusing JavaScript functions actually are.

Regular expressions var isint = /^\-?[0-9]+$/; var strs = ["888","bob","-282"]; for (var i = 0; i < strs.length; i++) document.write(strs[i]+":"+isint.test(strs[i])+" "); The test function returns true if the string matches the pattern described by the regular expression, false otherwise.

Regular expressions cheat sheet [0-9] means any digit [a-z] means any lowercase letter [A-Z] means any uppercase letter (x|y|z) means x or y or z * means 0 or more + means 1 or more ? means 0 or 1 {4-5} means four or five ^ means starts with $ means ends with. means just about any character \ is how you escape the special characters above

Regular expressions examples [0-9]{5} means five digits [A-Z][a-z]+ means an uppercase followed by at least one lowercase (maybe more) (Powerpoint|Open Office) means "Powerpoint" or "Open Office" (Rubicon|Rider) v\. [0-9]\.[0-9] matches "Rubicon v. 3.2" and "Rider v. 1.1" and "Rider v. 7.2", etc

Accessing elements on the page document.getElementById("myfield").value = 'x'; In a couple lectures, we will see how you can manipulate the web page's structure using JS.

Event handlers Text inputs have onchange events, buttons have onclick events (and so do most other HTML elements). On event, the code runs.

You can manipulate parts of the page in your event handlers. img { width: 3in; }

What's next for you… Refer to w3schools Walk through three of these JS examples – Including one of the "advanced" examples If you have any questions, ask your instructor!