CICS 515 a Internet Programming Week 3. Mike Feeley
|
|
- Elisabeth Marshall
- 5 years ago
- Views:
Transcription
1 CICS 515 a Internet Programming Week 3 Mike Feeley
2 JavaScript
3 JavaScript is not Java client-side scripting language program that runs in browser at client two ways to include it in HTML document embedded blah.html: <body> <script type="text/javascript"> document.write ("Hello from embedded JavaScript."); </script> </body> in separate file blah.html: <head> <script language="javascript" src="blah.js"></script> </head> blah.js: document.write ("Hello from separate file JavaScript.<br>");
4 JavaScript language constructs variables, objects and arrays functions conditionals loops exceptions Document Object Model (DOM) events
5 Variables in JavaScript dynamically typed type determined at runtime when value assigned any variable can store any value (of any type) types primitive types - Number, String, Boolean, Undefined, Null (wrapper classes have same name) - stored by value, like Java object references declaration no static types, so declare with var scope and lifetime globals declared outside of any function lifetime of document locals declared with var inside of a function lifetime of function invocation instance variables assigned this. inside of a method lifetime of object class variables assigned in prototype declaration lifetime of document
6 Dynamically typed objects fundamentally, an object is a collection of named properties referenced by a variable no class declaration --- classes are static types, Javascript has dynamic types creating an object new creates a new object reference add properties to object by assigning them values astudent = new Object (); astudent.sid = 10; astudent.name = 'First Student'; or using an initializer astudent = { sid: 10, name: 'First Student' ; you can add new properties to any object at any time document.mynewproperty = 48;
7 First-class functions one type of object property is a function first-class means that functions are also data members they can be assigned or re-assigned at runtime and/or passed as arguments to functions etc. declaring a function assign a function implementation to an object property name assigned or re-assigned dynamically, at runtime astudent.getsid = function () { return this.sid; ; writing a function use this. prefix to refer to object s properties (unlike Java, this. is required) invoking a function on an object invocation is just like Java ansid = astudent.getsid ();
8 Shared object properties terminology in Java an object is an instance of a class in JavaScript an object is an instance of constructor function and a shared prototype common constructor function name of function becomes name of the shared properties (like the class) function Student (ansid, aname) { this.sid = ansid; this.name = aname; this.getsid = function () { return this.sid; create a new instance by applying new to function name astudent = new Student (10,"First Student"); creates a copy of each property in every instance astudent = new Object(); astudent.student(10, First Student );
9 common prototype property of constructor function assigned to object implicitly when it is created so, every object created by a particular constructor shares the same prototype object function A () { A.prototype.x=1; prototype delegation when JavaScript looks for a property when accessed look in object, if not found look in prototype updating a delegated property, creates a local copy in object based on prototype s value function whenloaded () { var a0 = new A (); var a1 = new A (); var a2 = new A (); A.prototype.x = 3; a2.x = 2; alert(a0.x+', '+a1.x+', '+a2.x); what are values of a0.x, a1.x and a2.x?
10 Method declaration using prototypes share method among objects created same constructor function Student (ansid, aname) { this.sid = ansid; this.name = aname; Student.prototype.getSID = function () { return this.sid; ; use static initializer to create multiple prototype properties function Student (ansid, aname) { this.sid = ansid; this.name = aname; Student.prototype = { getsid: function () { return this.sid;, getname: function () { return this.name;
11 Delegation using prototypes delegation is key feature object-oriented inheritance in Java, subclass delegates to its superclass in JavaScript, object delegates to its prototype setting up the objects for delegation function Person (aname) { this.name = aname ""; Person.prototype.show = function () { alert (this.name); ; function Student (ansid) { this.sid = ansid ""; Student.prototype = new Person (); Student.prototype.show = function () { alert(this.name+" "+this.sid); ; function Instructor () { Instructor.prototype = new Person (); calling delegate s constructor function Student (ansid, aname) { this.prototypector = Person; this.prototypector (aname); this.sid = ansid;
12 or better... function Person (aname) { this.personctor = Person; this.name = aname ""; Person.prototype.show = function () { alert (this.name); ; function Student (aname, ansid) { this.studentctor = Student; this.personctor (aname); this.sid = ansid ""; Student.prototype = new Person (); Student.prototype.show = function () { alert(this.name+" "+this.sid); ; function Instructor () { Instructor.prototype = new Person (); function Person (aname) { this.name = aname ""; Person.prototype.show = function () { alert (this.name); ; Person.prototype.personCtor = Person; function Student (aname, ansid) { this.studentctor = Student; this.prototype.personctor (aname); this.sid = ansid ""; Student.prototype = new Person (); Student.prototype.show = function () { alert(this.name+" "+this.sid); ; function Instructor () { Instructor.prototype = new Person ();
13 Access-level modifiers in JavaScript key to modular design is encapsulation hiding some details of the implementation of an abstraction behind a public interface access-level modifiers are langauge features that implement encapsulation in Java: public, private, protected and package in JavaScript, support for access levels is poor public - any property assigned to an object or its prototype directly is public private - local variables created in object s constructor - visible to functions assigned to object, but not to is prototype s functions function Student (ansid, aname) { var refcount = 1; this.addreference = function () { refcount++; this.remreference = function () { refcount--; this.isreferenced = function () { refcount>0;
14 Inheritance and access limits don t combine well why doesn t this work? function RefObjectPrototype () { var refcount = 100; this.addreference = function () { refcount++; ; this.remreference = function () { refcount--; ; this.isreferenced = function () { return refcount; ; function Student (ansid, aname) { this.sid = ansid; this.name = aname; Student.prototype = new RefObjectPrototype (); Student.prototype.getSID = function () { return this.sid; ; Student.prototype.getName = function () { return this.name; ; one copy per call to RefObjectPrototype() not one per instance prototype instance properties must be be public function RefObjectPrototype () { this.refcount = 100; this.addreference = function () { this.refcount++; ; this.remreference = function () { this.refcount--; ; this.isreferenced = function () { return this.refcount; ;
15 Arrays in JavaScript declaring and initializing var c1 = new Array (3); var c2 = new Array ("red", "green", "blue"); var c3 = ["red", "green", "blue"]; var c4 = { 0: "red", 1: "blue", 2: "green"; getting (and setting) length c1[3] = "black"; // c1.length == 4 c1.length = 10; sorting, converting to a string c1.sort (); // c1 == ["blue", "green", "red"] var cs = c1.join(", "); // cs == "blue, green, red" var c5 = c1.concat ("yellow", "orange"); var c5 = c1.slice (2,4); // c5 == ["blue", "yellow"] stacks and queues c1.push ("new"); var x = c1.pop (); c1.shift ("new"); var x = x1.unshift ();
16 Loops and conditionals in JavaScript mainly like Java iterative with for (;;) { logical with while () { and do { while () exiting current iteration with continue and entire look with break conditionals with if () { { and switch () { iterating over collection for (variable in object) {... object[variable]... for (acolour in c1) { document.write (c1[acolour]); does not work with DOM NodeLists (more shortly) var coll = document.getelementsbyname ('x'); for (var item in coll) {... regular for loops always work var coll = document.getelementsbyname ('x'); for (var i=0; i<coll.length; i++) {...
17 exceptions throw e statement control is transferred to enclosing catch clause, if any any object (or value) can be used as e, the exception try { catch (e) { statement handles any exception thrown in try block e is bound to the object that was thrown unlike Java (or PHP), catch does not match an exception type <html> <body> <script type="text/javascript"> var x = prompt("enter a number between 0 and 10:","") try { if(x>10) throw "Err1" else if(x<0) throw "Err2" catch(er) { if(er=="err1") alert("error! The value is too high") else if(er == "Err2") alert("error! The value is too low") </script> </body> </html>
18 JavaScript Document Object Model (DOM) defines a object/event framework for elements of HTML page objects give JavaScript access to HTML objects events give HTML access to JavaScript functions the main standard objects are window - browser window and all of its content navigator - browser navigation document - document in a browser window
19 The window object in Javascript top-level object in JavaScript window. often left out when accessing window properties (e.g., alert) some useful elements of the window object open location focus moveto back close alert prompt resizeto setresizable screenx, screeny frames[] open a new window for URL change the document displayed in window set input focus to window change window position on client screen move to previous page close the window display an alert pop-up prompt the user for input change the size of the window determine whether window can be resized get window s position on client screen get an array of the frames within the window
20 <html> <body> <script type="text/javascript"> function openwindows () { var wina = window.open (" "A", "width=400,height=400"); var winb = window.open (" "B", "width=400, height=400, toolbar=no, scrollbars=no"); winb.focus (); wina.moveto (100,100); winb.moveto (400,400); </script> <a href="javascript: openwindows()">open Windows</a><br> </body> </html> notice also how to call JavaScript from a hyperlink
21 The navigator object in JavaScript some useful elements of the navigator object useragent identity of the browser platform operating system plugins[] list of installed browser plugins <html> <body> <script type="text/javascript"> function about () { document.write ("useragent: "+navigator.useragent+"<br>"); document.write ("platform: "+navigator.platform+"<br>"); for (var i=0; i<navigator.plugins.length; i++) { document.write ("plugin: "+navigator.plugins[i].name+"<br>"); </script> <a href="javascript: about()">about Me</a> </body> </html>
22 The document object in JavaScript collections anchors[] forms[] images[] links[] all the anchor objects all the form objects all the image objects all the area and link objects some properties body domain referrer URL body object IP domain name of document URL of document that loaded current document URL of current document some methods getelementbyid() locate object by its unique id getelementsbyname() list of objects with specified name (as NodeList) write() write HTML (or JavaScript) to document writeln() adds a new-line after writing
23 Element objects in Javascript each type of element has a set of properties here are some that are common to most elements classname title style name of element s CSS class advisory title style object innerhtml the HTML inside of the element (e.g., td or a) id name form unique id not-necessarily-unique name containing form (for inputs only)
24 Finding an element s object <body onload='whenloaded()'> <form name='formone' action=''> <input id='formone_one' name='one' type='text' size='20'> </form> <form name='formtwo' action=''> <input id='formtwo_one' name='one' type='text' size='20'> </form> </body> by reference from another object HTML documnet is a tree of objects rooted at the document object by ID document.forms[0].elements[0].style.bordercolor='blue'; unique among all elements in document document.getelementbyid('formone_one').style.bordercolor='red'; or with some JavsScript syntaxic sugar document.forms[0].formone_one.style.bordercolor='purple';
25 by Name need not be unique, access all elements with name var ones = document.getelementsbyname ('one'); for (var i=0; i<ones.length; i++) ones[i].style.bordercolor='orange'; access first with that name, or if name is unique document.getelementsbyname('one')[0].style.bordercolor='yellow'; or access first with syntatic sugar document.forms[0].one.style.bordercolor='green'; as this in HTML DOM event handler (more shortly) <input id='formone_one' name='one' type='text' size='20' onclick='this.style.bordercolor="grey"'>
26 The style and classname members used to change the display format of an element document.getelementbyid ( box100 ).style.color = blue ; document.getelementbyid ( box100 ).classname = moodybox ; generally using classname is better for same reason that CSS formatting is better than HTML-embedded formatting what were those reasons again? some of the properties of the style object color backgroundcolor font fontweight fontsize wordwrap textdecoration posleft visibility
27 <html> <body> <script type="text/javascript"> function changecolor (anid,acolor) { document.getelementbyid (anid).style.color=acolor; </script> <table><tr><td id="td0">zero</td><td id="td1">one</td></tr></table> <a href="javascript: changecolor('td1','red')">set Red</a> <a href="javascript: changecolor('td1','black')">set Black</a> </body> </html>
28 <html> <head> <style type='text/css'> *.highlight { color: red; *.nohighlight { color: black; </style> <script type='text/javascript'> var HIGHLIGHT_CLASS = 'highlight'; var NO_HIGHLIGHT_CLASS = 'nohighlight'; function setclassname (anid, aclassname) { document.getelementbyid (anid).classname = aclassname; </script> </head> <body> <table><tr><td id='td0'>zero</td><td id='td1'>one</td></tr></table> <a href="javascript: setclassname ('td1',highlight_class)">set Highlight</a> <a href="javascript: setclassname ('td1',no_highlight_class)">clear Highlight</a> </body> </html>
29 DOM prototype objects like other objects, DOM objects have prototypes too naming convention HTML + name-of-element + Element.prototype e.g., HTMLInputElement.prototype use this to add a property to all objects of some type e.g., add new method to Input DOM object HTMLInputElement.prototype.newMethod = function (arg) {... ;
30 Events HTML elements can define JavaScript event handlers here are some events than can have handlers onsubmit onclick when form is submitted when element is clicked on onmouseover when mouse pointer enters element onmouseout onkeydown onkeyup onload onchange onfocus onblur when mouse pointer leaves element when key is press when element has focus when key is released when element has focus when page finishes loading when value of element changes when element receives input focus when element looses input focus
31 For example set select box when name changes... <script type="text/javacript"> function checkbox (row) { document.getelementbyid('checkbox'+row).checked = true; </script>... for ($i=0; $i<mysql_numrows($rows); $i++) { $sid = mysql_result ($rows, $i, 'sid'); $name = mysql_result ($rows, $i, 'name'); echo "<tr>\n"; echo "<td><input id='checkbox$i' "; echo "name='selected[]' type='checkbox' value='$i'>\n"; echo "<td>$sid<input type='hidden' name='sid[]' value='$sid'>\n"; echo "<td><input name='name[]' type='text' size='30' value='$name'"; echo "onchange='checkbox($i)'>\n"; echo "</tr>\n";
32 or disable name input until select box is checked <script type="text/javascript"> function checkbox (row) { var box = document.getelementbyid('checkbox'+row); var name = document.getelementbyid('name'+row); name.disabled =!box.checked; </script>... echo "<td><input id='checkbox$i' "; echo "name='selected[]' type='checkbox' value='$i'"; echo " onchange='checkbox($i)'>\n"; echo "<td>$sid<input type='hidden' name='sid[]' value='$sid'>\n"; echo "<td><input id='name$i' name='name[]' type='text' size='30'"; echo " value='$name' disabled='true'>\n";
CICS 515 b Internet Programming Week 2. Mike Feeley
CICS 515 b Internet Programming Week 2 Mike Feeley 1 Software infrastructure stuff MySQL and PHP store files in public_html run on remote.mss.icics.ubc.ca access as http://ws.mss.icics.ubc.ca/~username/...
More informationLECTURE-3. Exceptions JS Events. CS3101: Programming Languages: Javascript Ramana Isukapalli
LECTURE-3 Exceptions JS Events 1 EXCEPTIONS Syntax and usage Similar to Java/C++ exception handling try { // your code here catch (excptn) { // handle error // optional throw 2 EXCEPTIONS EXAMPLE
More informationIntroduction to JavaScript p. 1 JavaScript Myths p. 2 Versions of JavaScript p. 2 Client-Side JavaScript p. 3 JavaScript in Other Contexts p.
Preface p. xiii Introduction to JavaScript p. 1 JavaScript Myths p. 2 Versions of JavaScript p. 2 Client-Side JavaScript p. 3 JavaScript in Other Contexts p. 5 Client-Side JavaScript: Executable Content
More informationCSC Javascript
CSC 4800 Javascript See book! Javascript Syntax How to embed javascript between from an external file In an event handler URL - bookmarklet
More informationJavaScript and XHTML. Prof. D. Krupesha, PESIT, Bangalore
JavaScript and XHTML Prof. D. Krupesha, PESIT, Bangalore Why is JavaScript Important? It is simple and lots of scripts available in public domain and easy to use. It is used for client-side scripting.
More informationCOMP519 Web Programming Lecture 16: JavaScript (Part 7) Handouts
COMP519 Web Programming Lecture 16: JavaScript (Part 7) Handouts Ullrich Hustadt Department of Computer Science School of Electrical Engineering, Electronics, and Computer Science University of Liverpool
More informationWeb Programming and Design. MPT Junior Cycle Tutor: Tamara Demonstrators: Aaron, Marion, Hugh
Web Programming and Design MPT Junior Cycle Tutor: Tamara Demonstrators: Aaron, Marion, Hugh Plan for the next 5 weeks: Introduction to HTML tags, creating our template file Introduction to CSS and style
More informationCE212 Web Application Programming Part 2
CE212 Web Application Programming Part 2 22/01/2018 CE212 Part 2 1 JavaScript Event-Handlers 1 JavaScript may be invoked to handle input events on HTML pages, e.g.
More informationFundamentals of Website Development
Fundamentals of Website Development CSC 2320, Fall 2015 The Department of Computer Science Events handler Element with attribute onclick. Onclick with call function Function defined in your script or library.
More informationLECTURE-2. Functions review HTML Forms. Arrays Exceptions Events. CS3101: Scripting Languages: Javascript Ramana Isukapalli
LECTURE-2 Functions review HTML Forms Arrays Exceptions Events 1 JAVASCRIPT FUNCTIONS, REVIEW Syntax function (params) { // code Note: Parameters do NOT have variable type. 1. Recall: Function
More informationWeb Site Development with HTML/JavaScrip
Hands-On Web Site Development with HTML/JavaScrip Course Description This Hands-On Web programming course provides a thorough introduction to implementing a full-featured Web site on the Internet or corporate
More informationSession 16. JavaScript Part 1. Reading
Session 16 JavaScript Part 1 1 Reading Reading Wikipedia en.wikipedia.org/wiki/javascript / p W3C www.w3.org/tr/rec-html40/interact/scripts.html Web Developers Notes www.webdevelopersnotes.com/tutorials/javascript/
More information710 Index Attributes, 127 action attribute, 263 assigning, bottom attribute, domain name attribute, 481 expiration date attribute, 480 8
INDEX Symbols = (assignment operator), 56 \ (backslash), 33 \b (backspace), 33 \" (double quotation mark), 32 \e (escape), 33 \f (form feed), 33
More informationLecture 3: The Basics of JavaScript. Background. Needs for Programming Capability. Origin of JavaScript. Using Client-side JavaScript
Lecture 3: The Basics of JavaScript Wendy Liu CSC309F Fall 2007 Background Origin and facts 1 2 Needs for Programming Capability XHTML and CSS allows the browser to passively display static content How
More informationHTML User Interface Controls. Interactive HTML user interfaces. Document Object Model (DOM)
Page 1 HTML User Interface Controls CSE 190 M (Web Programming), Spring 2007 University of Washington Reading: Sebesta Ch. 5 sections 5.1-5.7.2, Ch. 2 sections 2.9-2.9.4 Interactive HTML user interfaces
More informationNew Perspectives on Creating Web Pages with HTML. Tutorial Objectives
New Perspectives on Creating Web Pages with HTML Tutorial 9: Working with JavaScript Objects and Events 1 Tutorial Objectives Learn about form validation Study the object-based nature of the JavaScript
More informationCISH-6510 Web Application Design and Development. Overview of JavaScript. Overview
CISH-6510 Web Application Design and Development Overview of JavaScript Overview What is JavaScript? History Uses of JavaScript Location of Code Simple Alert Example Events Events Example Color Example
More informationNew Media Production Lecture 7 Javascript
New Media Production Lecture 7 Javascript Javascript Javascript and Java have almost nothing in common. Netscape developed a scripting language called LiveScript. When Sun developed Java, and wanted Netscape
More informationJavaScript Programming
JavaScript Programming Course ISI-1337B - 5 Days - Instructor-led, Hands on Introduction Today, JavaScript is used in almost 90% of all websites, including the most heavilytrafficked sites like Google,
More informationChapter4: HTML Table and Script page, HTML5 new forms. Asst. Prof. Dr. Supakit Nootyaskool Information Technology, KMITL
Chapter4: HTML Table and Script page, HTML5 new forms Asst. Prof. Dr. Supakit Nootyaskool Information Technology, KMITL Objective To know HTML5 creating a new style form. To understand HTML table benefits
More informationWeb Programming/Scripting: JavaScript
CS 312 Internet Concepts Web Programming/Scripting: JavaScript Dr. Michele Weigle Department of Computer Science Old Dominion University mweigle@cs.odu.edu http://www.cs.odu.edu/~mweigle/cs312-f11/ 1 Outline!
More informationEvents: another simple example
Internet t Software Technologies Dynamic HTML part two IMCNE A.A. 2008/09 Gabriele Cecchetti Events: another simple example Every element on a web page has certain events which can trigger JavaScript functions.
More informationSkyway Builder Web Control Guide
Skyway Builder Web Control Guide 6.3.0.0-07/21/2009 Skyway Software Skyway Builder Web Control Guide: 6.3.0.0-07/21/2009 Skyway Software Published Copyright 2009 Skyway Software Abstract TBD Table of
More informationClient vs Server Scripting
Client vs Server Scripting PHP is a server side scripting method. Why might server side scripting not be a good idea? What is a solution? We could try having the user download scripts that run on their
More informationMobile Site Development
Mobile Site Development HTML Basics What is HTML? Editors Elements Block Elements Attributes Make a new line using HTML Headers & Paragraphs Creating hyperlinks Using images Text Formatting Inline styling
More informationWeb Development & Design Foundations with HTML5
1 Web Development & Design Foundations with HTML5 CHAPTER 14 A BRIEF LOOK AT JAVASCRIPT Copyright Terry Felke-Morris 2 Learning Outcomes In this chapter, you will learn how to: Describe common uses of
More informationCSC Web Programming. JavaScript Browser Objects
CSC 242 - Web Programming JavaScript Browser Objects JavaScript Object Types User defined objects Native objects (Array, Math, Date, etc.) Host Objects provided by the browser The window object is a representation
More informationJavaScript. What s wrong with JavaScript?
JavaScript 1 What s wrong with JavaScript? A very powerful language, yet Often hated Browser inconsistencies Misunderstood Developers find it painful Lagging tool support Bad name for a language! Java
More informationPlace User-Defined Functions in the HEAD Section
JavaScript Functions Notes (Modified from: w3schools.com) A function is a block of code that will be executed when "someone" calls it. In JavaScript, we can define our own functions, called user-defined
More informationSession 6. JavaScript Part 1. Reading
Session 6 JavaScript Part 1 Reading Reading Wikipedia en.wikipedia.org/wiki/javascript Web Developers Notes www.webdevelopersnotes.com/tutorials/javascript/ JavaScript Debugging www.w3schools.com/js/js_debugging.asp
More informationSuch JavaScript Very Wow
Such JavaScript Very Wow Lecture 9 CGS 3066 Fall 2016 October 20, 2016 JavaScript Numbers JavaScript numbers can be written with, or without decimals. Extra large or extra small numbers can be written
More informationIntroduction to DHTML
Introduction to DHTML HTML is based on thinking of a web page like a printed page: a document that is rendered once and that is static once rendered. The idea behind Dynamic HTML (DHTML), however, is to
More informationJavaScript: Events, DOM and Attaching Handlers
JavaScript: Events, DOM and Attaching Handlers CISC 282 October 11, 2017 Keyboard and Text Events Name The User Must Applicable Elements blur remove focus , ,... focus apply focus , ,...
More informationJavaScript Introduction
JavaScript Introduction Web Technologies I. Zsolt Tóth University of Miskolc 2016 Zsolt Tóth (UM) JavaScript Introduction 2016 1 / 31 Introduction Table of Contents 1 Introduction 2 Syntax Variables Control
More informationJavaScript Handling Events Page 1
JavaScript Handling Events Page 1 1 2 3 4 5 6 7 8 Handling Events JavaScript JavaScript Events (Page 1) An HTML event is something interesting that happens to an HTML element Can include: Web document
More informationIntroduction to Programming Using Java (98-388)
Introduction to Programming Using Java (98-388) Understand Java fundamentals Describe the use of main in a Java application Signature of main, why it is static; how to consume an instance of your own class;
More informationControlled Assessment Task. Question 1 - Describe how this HTML code produces the form displayed in the browser.
Controlled Assessment Task Question 1 - Describe how this HTML code produces the form displayed in the browser. The form s code is displayed in the tags; this creates the object which is the visible
More informationBy the end of this section of the practical, the students should be able to:
By the end of this section of the practical, the students should be able to: Learn about the Document Object Model and the Document Object Model hierarchy Create and use the properties, methods and event
More information8/19/2018. Web Development & Design Foundations with HTML5. Learning Objectives (1 of 2) Learning Objectives (2 of 2) What is JavaScript?
Web Development & Design Foundations with HTML5 Ninth Edition Chapter 14 A Brief Look at JavaScript and jquery Slides in this presentation contain hyperlinks. JAWS users should be able to get a list of
More informationPearson Education Limited Edinburgh Gate Harlow Essex CM20 2JE England and Associated Companies throughout the world
Pearson Education Limited Edinburgh Gate Harlow Essex CM20 2JE England and Associated Companies throughout the world Visit us on the World Wide Web at: www.pearsoned.co.uk Pearson Education Limited 2014
More informationCHAPTER 6 JAVASCRIPT PART 1
CHAPTER 6 JAVASCRIPT PART 1 1 OVERVIEW OF JAVASCRIPT JavaScript is an implementation of the ECMAScript language standard and is typically used to enable programmatic access to computational objects within
More informationWeb Programming Step by Step
Web Programming Step by Step Lecture 15 Unobtrusive JavaScript Reading: 8.1-8.3 Except where otherwise noted, the contents of this presentation are Copyright 2009 Marty Stepp and Jessica Miller. 8.1: Global
More informationJavascript Lecture 23
Javascript Lecture 23 Robb T. Koether Hampden-Sydney College Mar 9, 2012 Robb T. Koether (Hampden-Sydney College) JavascriptLecture 23 Mar 9, 2012 1 / 23 1 Javascript 2 The Document Object Model (DOM)
More informationINTRODUCTION TO JAVASCRIPT
INTRODUCTION TO JAVASCRIPT Overview This course is designed to accommodate website designers who have some experience in building web pages. Lessons familiarize students with the ins and outs of basic
More informationJavaScript II CSCI 311 SPRING 2017
JavaScript II CSCI 311 SPRING 2017 Overview Look at more JavaScript functionality DOM slide show preloading images pull down menus and more! Document Object Model DOM gives us ways to access elements of
More informationJavascript. Many examples from Kyle Simpson: Scope and Closures
Javascript Many examples from Kyle Simpson: Scope and Closures What is JavaScript? Not related to Java (except that syntax is C/Java- like) Created by Brendan Eich at Netscape later standardized through
More informationWhat Is JavaScript? A scripting language based on an object-orientated programming philosophy.
What Is JavaScript? A scripting language based on an object-orientated programming philosophy. Each object has certain attributes. Some are like adjectives: properties. For example, an object might have
More informationJavaScript: Introduction, Types
JavaScript: Introduction, Types Computer Science and Engineering College of Engineering The Ohio State University Lecture 19 History Developed by Netscape "LiveScript", then renamed "JavaScript" Nothing
More informationNetscape Introduction to the JavaScript Language
Netscape Introduction to the JavaScript Language Netscape: Introduction to the JavaScript Language Eckart Walther Netscape Communications Serving Up: JavaScript Overview Server-side JavaScript LiveConnect:
More informationPrinceton University COS 333: Advanced Programming Techniques A Subset of JavaScript
Princeton University COS 333: Advanced Programming Techniques A Subset of JavaScript Program Structure function sqr(i) var result; // Otherwise result would be global. result = i * i; //
More informationKey features. Nothing to do with java It is the Client-side scripting language Designed to add interactivity to HTML pages
Javascript Key features Nothing to do with java It is the Client-side scripting language Designed to add interactivity to HTML pages (DHTML): Event-driven programming model AJAX Great example: Google Maps
More informationLecture 14. Introduction to JavaScript. Mr. Mubashir Ali Lecturer (Dept. of Computer Science)
Lecture 14 Introduction to JavaScript Mr. Mubashir Ali Lecturer (Dept. of dr.mubashirali1@gmail.com 1 Outline What is JavaScript? Embedding JavaScript with HTML JavaScript conventions Variables in JavaScript
More information1$ 5 ! $ 6 4 * Source: 0 "!*! 0! * 8 97 ?!$ 5 0 *! 4! $ 0 : * ' () 7;7 7<7
!#! # %! ' ()!* +, -.!/ *! * 1 !!
More informationCISC 1600 Lecture 2.4 Introduction to JavaScript
CISC 1600 Lecture 2.4 Introduction to JavaScript Topics: Javascript overview The DOM Variables and objects Selection and Repetition Functions A simple animation What is JavaScript? JavaScript is not Java
More informationQ1. What is JavaScript?
Q1. What is JavaScript? JavaScript was designed to add interactivity to HTML pages JavaScript is a scripting language A scripting language is a lightweight programming language JavaScript is usually embedded
More informationWant to add cool effects like rollovers and pop-up windows?
Chapter 10 Adding Interactivity with Behaviors In This Chapter Adding behaviors to your Web page Creating image rollovers Using the Swap Image behavior Launching a new browser window Editing your behaviors
More informationNotes on JavaScript (aka ECMAScript) and the DOM
Notes on JavaScript (aka ECMAScript) and the DOM JavaScript highlights: Syntax and control structures superficially resemble Java/C/C++ Dynamically typed Has primitive types and strings (which behave more
More informationSections and Articles
Advanced PHP Framework Codeigniter Modules HTML Topics Introduction to HTML5 Laying out a Page with HTML5 Page Structure- New HTML5 Structural Tags- Page Simplification HTML5 - How We Got Here 1.The Problems
More informationCSI 3140 WWW Structures, Techniques and Standards. Browsers and the DOM
CSI 3140 WWW Structures, Techniques and Standards Browsers and the DOM Overview The Document Object Model (DOM) is an API that allows programs to interact with HTML (or XML) documents In typical browsers,
More informationProgramming for the Web with PHP
Aptech Ltd Version 1.0 Page 1 of 11 Table of Contents Aptech Ltd Version 1.0 Page 2 of 11 Abstraction Anonymous Class Apache Arithmetic Operators Array Array Identifier arsort Function Assignment Operators
More informationAP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS
AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS PAUL L. BAILEY Abstract. This documents amalgamates various descriptions found on the internet, mostly from Oracle or Wikipedia. Very little of this
More informationCSC Web Programming. Introduction to JavaScript
CSC 242 - Web Programming Introduction to JavaScript JavaScript JavaScript is a client-side scripting language the code is executed by the web browser JavaScript is an embedded language it relies on its
More informationPhoto from DOM
Photo from http://www.flickr.com/photos/emraya/2861149369/ DOM 2 DOM When a browser reads an HTML file, it must interpret the file and render it onscreen. This process is sophisticated. Fetch Parse Flow
More informationJavaScript Specialist v2.0 Exam 1D0-735
JavaScript Specialist v2.0 Exam 1D0-735 Domain 1: Essential JavaScript Principles and Practices 1.1: Identify characteristics of JavaScript and common programming practices. 1.1.1: List key JavaScript
More informationBasics of JavaScript. Last Week. Needs for Programming Capability. Browser as Development Platform. Using Client-side JavaScript. Origin of JavaScript
Basics of JavaScript History of the Web XHTML CSS Last Week Nan Niu (nn@cs.toronto.edu) CSC309 -- Fall 2008 2 Needs for Programming Capability XHTML and CSS allows the browser to passively display static
More informationE ECMAScript, 21 elements collection, HTML, 30 31, 31. Index 161
A element, 108 accessing objects within HTML, using JavaScript, 27 28, 28 activatediv()/deactivatediv(), 114 115, 115 ActiveXObject, AJAX and, 132, 140 adding information to page dynamically, 30, 30,
More informationIntroduction to using HTML to design webpages
Introduction to using HTML to design webpages #HTML is the script that web pages are written in. It describes the content and structure of a web page so that a browser is able to interpret and render the
More informationCITS3403 Agile Web Development Semester 1, 2018
Javascript Event Handling CITS3403 Agile Web Development Semester 1, 2018 Event Driven Programming Event driven programming or event based programming programming paradigm in which the flow of the program
More informationWeb Development & Design Foundations with HTML5, 8 th Edition Instructor Materials Chapter 14 Test Bank
Multiple Choice. Choose the best answer. 1. JavaScript can be described as: a. an object-oriented scripting language b. an easy form of Java c. a language created by Microsoft 2. Select the true statement
More informationIntroduction to JavaScript Programming Test Bank Chapter 1 with XML and PHP
Test Bank for Introduction to JavaScript Programming 1 st Edition by rake Link download full: http://testbankcollection.com/download/test-bank-for-introduction-to-javascriptprogramming-with-xml-and-php-1st-edition-by-drake
More informationCOMS 469: Interactive Media II
COMS 469: Interactive Media II Agenda Review Ch. 5: JavaScript An Object-Based Language Ch. 6: Programming the Browser Review Data Types & Variables Data Types Numeric String Boolean Variables Declaring
More informationIS 242 Web Application Development I
IS 242 Web Application Development I Lecture 11: Introduction to JavaScript (Part 4) Marwah Alaofi Outlines of today s lecture Events Assigning events using DOM Dom nodes Browser Object Model (BOM) 2 Event
More informationBy the end of this section of the practical, the students should be able to:
By the end of this section of the practical, the students should be able to: Write JavaScript to generate HTML Create simple scripts which include input and output statements, arithmetic, relational and
More information(Refer Slide Time: 01:40)
Internet Technology Prof. Indranil Sengupta Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur Lecture No #25 Javascript Part I Today will be talking about a language
More informationCorresponds to a layer in an HTML page and provides a means for manipulating that layer. Client-side object Implemented in JavaScript 1.
Layer Layer Corresponds to a layer in an HTML page and provides a means for manipulating that layer. Client-side object Created by The HTML LAYER or ILAYER tag, or using cascading style sheet syntax. The
More informationPIC 40A. Midterm 1 Review
PIC 40A Midterm 1 Review XHTML and HTML5 Know the structure of an XHTML/HTML5 document (head, body) and what goes in each section. Understand meta tags and be able to give an example of a meta tags. Know
More informationPrinceton University COS 333: Advanced Programming Techniques A Subset of JavaScript
Princeton University COS 333: Advanced Programming Techniques A Subset of JavaScript Program Structure function sqr(i) var result; // Otherwise result would be global. result = i * i; //
More informationWeb Designing Course
Web Designing Course Course Summary: HTML, CSS, JavaScript, jquery, Bootstrap, GIMP Tool Course Duration: Approx. 30 hrs. Pre-requisites: Familiarity with any of the coding languages like C/C++, Java etc.
More informationWeiss Chapter 1 terminology (parenthesized numbers are page numbers)
Weiss Chapter 1 terminology (parenthesized numbers are page numbers) assignment operators In Java, used to alter the value of a variable. These operators include =, +=, -=, *=, and /=. (9) autoincrement
More informationJavaScript s role on the Web
Chris Panayiotou JavaScript s role on the Web JavaScript Programming Language Developed by Netscape for use in Navigator Web Browsers Purpose make web pages (documents) more dynamic and interactive Change
More informationCOMS W3101: SCRIPTING LANGUAGES: JAVASCRIPT (FALL 2017)
COMS W3101: SCRIPTING LANGUAGES: JAVASCRIPT (FALL 2017) RAMANA ISUKAPALLI RAMANA@CS.COLUMBIA.EDU 1 LECTURE-1 Course overview See http://www.cs.columbia.edu/~ramana Overview of HTML Formatting, headings,
More informationGovt. of Karnataka, Department of Technical Education Diploma in Computer Science & Engineering. Fifth Semester. Subject: Web Programming
Govt. of Karnataka, Department of Technical Education Diploma in Computer Science & Engineering Fifth Semester Subject: Web Programming Contact Hrs / week: 4 Total hrs: 64 Table of Contents SN Content
More informationJavaScript. Asst. Prof. Dr. Kanda Saikaew Dept. of Computer Engineering Khon Kaen University
JavaScript Asst. Prof. Dr. Kanda Saikaew (krunapon@kku.ac.th) Dept. of Computer Engineering Khon Kaen University 1 Why Learn JavaScript? JavaScript is used in millions of Web pages to Validate forms Detect
More informationCERTIFICATE IN WEB PROGRAMMING
COURSE DURATION: 6 MONTHS CONTENTS : CERTIFICATE IN WEB PROGRAMMING 1. PROGRAMMING IN C and C++ Language 2. HTML/CSS and JavaScript 3. PHP and MySQL 4. Project on Development of Web Application 1. PROGRAMMING
More informationCGS 3066: Spring 2015 JavaScript Reference
CGS 3066: Spring 2015 JavaScript Reference Can also be used as a study guide. Only covers topics discussed in class. 1 Introduction JavaScript is a scripting language produced by Netscape for use within
More informationIntroduction to JavaScript, Part 2
Introduction to JavaScript, Part 2 Luka Abrus Technology Specialist, Microsoft Croatia Interaction In the first part of this guide, you learned how to use JavaScript, how to write code and how to see if
More informationJavaScript CS 4640 Programming Languages for Web Applications
JavaScript CS 4640 Programming Languages for Web Applications 1 How HTML, CSS, and JS Fit Together {css} javascript() Content layer The HTML gives the page structure and adds semantics Presentation
More informationJavaScript CS 4640 Programming Languages for Web Applications
JavaScript CS 4640 Programming Languages for Web Applications 1 How HTML, CSS, and JS Fit Together {css} javascript() Content layer The HTML gives the page structure and adds semantics Presentation
More informationCSS The web browser uses its own resources, and eases the burden on the server. It has fewer features than server side scripting.
What is JavaScript? HTML and CSS concentrate on a static rendering of a page; things do not change on the page over time, or because of events. To do these things, we use scripting languages, which allow
More informationPace University. Fundamental Concepts of CS121 1
Pace University Fundamental Concepts of CS121 1 Dr. Lixin Tao http://csis.pace.edu/~lixin Computer Science Department Pace University October 12, 2005 This document complements my tutorial Introduction
More informationJAVASCRIPT BASICS. Handling Events In JavaScript. In programing, event-driven programming could be a programming
Handling s In JavaScript In programing, event-driven programming could be a programming paradigm during which the flow of the program is set by events like user actions (mouse clicks, key presses), sensor
More informationOO and Ahh! An Introduction to Object Oriented Programming With PHP. Division 1 Systems. John Valance. Copyright John Valance Division 1 Systems
OO and Ahh! An Introduction to Object Oriented Programming With PHP John Valance Division 1 Systems johnv@div1sys.com Copyright John Valance Division 1 Systems About John Valance 30+ years IBM midrange
More informationLesson 5 Introduction to Cascading Style Sheets
Introduction to Cascading Style Sheets HTML and JavaScript BASICS, 4 th Edition 1 Objectives Create a Cascading Style Sheet. Control hyperlink behavior with CSS. Create style classes. Share style classes
More informationDOM Primer Part 2. Contents
DOM Primer Part 2 Contents 1. Event Programming 1.1 Event handlers 1.2 Event types 1.3 Structure modification 2. Forms 2.1 Introduction 2.2 Scripting interface to input elements 2.2.1 Form elements 2.2.2
More informationCS1046 Lab 4. Timing: This lab should take you 85 to 130 minutes. Objectives: By the end of this lab you should be able to:
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: Define the terms: function, calling and user-defined function and predefined function
More informationChapter 6 Introduction to Defining Classes
Introduction to Defining Classes Fundamentals of Java: AP Computer Science Essentials, 4th Edition 1 Objectives Design and implement a simple class from user requirements. Organize a program in terms of
More informationThis course is designed for web developers that want to learn HTML5, CSS3, JavaScript and jquery.
HTML5/CSS3/JavaScript Programming Course Summary Description This class is designed for students that have experience with basic HTML concepts that wish to learn about HTML Version 5, Cascading Style Sheets
More informationA.A. 2008/09. Why introduce JavaScript. G. Cecchetti Internet Software Technologies
Internet t Software Technologies JavaScript part one IMCNE A.A. 2008/09 Gabriele Cecchetti Why introduce JavaScript To add dynamicity and interactivity to HTML pages 2 What s a script It s a little interpreted
More informationJavaScript. Training Offer for JavaScript Introduction JavaScript. JavaScript Objects
JavaScript CAC Noida is an ISO 9001:2015 certified training center with professional experience that dates back to 2005. The vision is to provide professional education merging corporate culture globally
More informationTEXTAREA NN 2 IE 3 DOM 1
778 TEXTAREA Chapter 9DOM Reference TEXTAREA NN 2 IE 3 DOM 1 The TEXTAREA object reflects the TEXTAREA element and is used as a form control. This object is the primary way of getting a user to enter multiple
More information