JavaScript. Jef De Smedt Beta VZW

Size: px
Start display at page:

Download "JavaScript. Jef De Smedt Beta VZW"

Transcription

1 JavaScript Jef De Smedt Beta VZW

2 Getting to know Beta VZW: Association founded in 1993 Computer courses for the unemployed and for employees Cevora VZW/Cefora ASBL 09:00u-12:30u 13:00u-16:30u

3 Getting to know you Name Role/Function in your organisation Experience with HTML/CSS Programming languages JavaScript Expectations

4 Overview Introduction Basic elements of JavaScript Arrays Window object Document Object Model Forms Events Objects Introduction to TypeScript

5 Introduction: what is JavaScript Scripting language, 1995, Brendan Eich (Netscape Communications Corporation) Ease integration between Java applets and HTML page <html> Java applet Java applet: Java program in browser Richer user interface Compare with Flash, Silverlight Can only be used when Java is installed locally </html>

6 Introduction: what is JavaScript? Scripting language, 1995, Brendan Eich (Netscape Communications Corporation) Ease integration between Java applets and HTML page Dynamic HMTL pages

7 Introduction: what is JavaScript? Scripting language, 1995, Brendan Eich (Netscape Communications Corporation) Ease integration between Java applets and HTML page Dynamic HMTL pages AJAX (Asynchronous JavaScript and XML) XML/JSON Web page Server

8 Introduction: history Same year(1995): Microsoft, own version (Jscript) Compatibility problems 1997: standard, European Computer Manufacturers Association EcmaScript = JavaScript language without browser support Implementations of EcmaScript: JavaScript, JScript, ActionScript, Most browsers implement the most important features of EcmaScript 6

9 Introduction: JavaScript = bad programming? Not a real programming language Incompatibilities between different browsers Gained popularity because of new libraries and frameworks (JQuery, Modernizr, AngularJS, React, Backbone, ) Also more popular on the server side: node.js

10 JavaScript vs Java JavaScript Case sensitive { } => blocks End statement with semicolon; Declaration of variables: var i = 42; var name = John ; var isvalid = true; Dynamically typed var i = 42; i = John ; Java Case sensitive { } => blocks End statement with semicolon; Declaration of variables: int i = 42; String name = John ; boolean isvalid= true; Statically typed int i = 42; i = John ; The difference between Java and JavaScript is as big as the difference between ham and hamster

11 Write JavaScript code (in a browser) JavaScript code between <script> tags Attribute type= text/javascript is not necessary anymore (default in HTML5) <!DOCTYPE html> <html> <head> <title>javascript</title> </head> <body> </body> </html> <script> console.log( Hi world ); </script>

12 Write JavaScript code (in a browser) Index.html <!DOCTYPE html> <html> <head> <title>javascript</title> <script src= index.js ></script> </head> <body> </body> </html> Index.js console.log( hi world ); Closing script tag is mandatory in HTML5

13 Write JavaScript code (in a browser) Press F12 (developer tools) Choose Console tab => output of console.log.

14 Noscript element The contents of the <noscript>-element is shown when the browser does not support JavaScript <script> and <noscript> are mutually exclusive <html> <head> </head> <body> <noscript>use a browser that supports JavaScript</noscript> </body> </html>

15 Noscript element <noscript> can be used in <head> and <body> When used in <head> it should only contain <link>, <meta> and <style>elements <noscript> can be used in graceful degradation => when taking away JavaScript possibilities the page should still function(more or less) Nowadays: progressive enhancement => start with a page that works without JavaScript and add functionality that makes the page work better.

16 JavaScript types var i = 42; // number (integer, floating point) var name = John ; //string var isvalid = true; // boolean var value; //undefined var empty = null; //null var list = [ John, Paul, Ringo, George ]; //object (array) var person = {name: John, address: 9 Newcastle road }; //object (EcmaScript 6) var s = new Symbol( key ); //symbol

17 Working with types JavaScript uses dynamic typing: var i = 7; i = John ; JavaScript uses type coercion var number = ; console.log(number); //42 See the result of coercion: Number( 4 ); //4 Boolean(1); //true Boolean(null); // false String(4); // 4 The number 4 is coerced into a string: The plusoperator for strings means: concatenate

18 Prompting and alerting <!DOCTYPE html> <html> <head> <title>prompting and alerting</title> <script> var number1 = prompt("give first number"); var number2 = prompt("give second number"); var sum = number1 + number2; alert(sum); </script> </head> <body> </body> </html> Prompt-function returns a string

19 Converting to integer <!DOCTYPE html> <html> <head> <title>prompting and alerting (int)</title> <script> var number1 = prompt("give first number"); number1 = parseint(number1); var number2 = prompt("give second number"); number2 = parseint(number2); var sum = number1 + number2; alert(sum); </script> </head> <body> </body> </html> parseint converts a string into a number. (faster than Number() in IE and Firefox. See The fastest way to convert a String into a number in Chrome: number1 = +number1;

20 Document.write <!DOCTYPE html> <html> <head> <title>prompting and alerting (document.write)</title> </head> <body> </body> </html> <script> var number1 = prompt("give first number"); number1 = parseint(number1); var number2 = prompt("give second number"); number2 = parseint(number2); var sum = number1 + number2; document.write(number number2 + = +sum); </script> document.write writes the argument in de body of the HTML document

21 JavaScript arithmetic/string operators Operator Description Example + Adds two numbers var n = 6 + 5; //11 + Concatenates two strings var n = ; // 65 - Subtracts two numbers var n = 6 5; // 1 * Multiplies two numbers var n = 6 * 5; // 30 / Divides two numbers var n = 6 / 5; // 1.2 % Takes the modulo (remainder of division) var n = 6 % 5; // 1 ++ Increment operator var n = 6; ++n; //7 -- Decrement operator var n = 6; n--;// 5

22 JavaScript assignment operators Operator Description Example = Assigns a value to another value var a=6, b=8; // a is equal to 6, b is equal to 8 += Adds a value to a variable var a=6; var a += 3;//9 (a=a+3) -= Subtracts a value from a variable var a=6; var a -= 3; //4 (a=a-3) *= Multiply a value and a variable var a=6; var a*= 3; //18 (a=a*3) /= Divides a variable by a value var a=6; var a/=3; // 2 (a=a/3)

23 Greetings

24 Age

25 People

26 If statement if (test_that_evaluates_to_true_or_false) { code_that_will_be_executed_when_test_is_true } if (test_that_evaluates_to_true_or_false) { code_that_will_be_executed_when_test_is_true } else { } code_that_will_be_executed_when_test_is_false

27 If statement example var now= new Date(); var hour = now.gethours(); if (hour < 12){ alert( Good morning"); }else{ alert( Good afternoon"); }

28 If statement example var now = new Date(); var hour = now.gethours(); if (hour == 9){ document.write( Around nine: coffee time"); }else if (hour==12) { document.write( Between twelve and one: everyone is gone"); }else if (hour == 17){ document.write( Seventeen?: bring in the caffeine"); }else{ document.write( Time to work"); }

29 JavaScript equality operators Operator Description Example == Compares two values for equality var a=7, b= 7 ; var test = a == b; //true === Compares two values and their types for equality var a=7, b= 7 ; var test = a === b;//false!= Compares two values for inequality var a=7, b= 7 ; var test = a!= b; //false!== Compares two values and their types for inequality var a=7, b= 7 ; var test = a!== b; //true

30 JavaScript comparison operators Operator Description Example < Less than var a=7, b=8; var test = a < b; //true > Greater than var a=7, b=6; var test = a > b;//true <= Less than or equal var a=7, b=7; var test = a <= b; //true >= Greater than or equal var a=7, b=7; var test = a>= b; //true Instanceof Is Object of certain type var d = new Date(); var test = d instanceof Date; // true

31 JavaScript logical operators Operator Description Example && And (both must be true in order for the result to be true) Or (At least one must be true in order for the result to be true)! Not (true becomes false and false becomes true) var a=true, b=false; var test = a && b; //false var a=true, b=false; var test = a b;//true var a=true; var test =!a; //false

32 Profit/loss What do you do when income equals expenses?

33 What is your name? An empty string in JavaScript: or (two single quotes)

34 Old enough to visit website(at least 18) Can you write it in such a way that it will still work correctly next year (i.e. not only in 2017?)

35 Switch statement switch(value) { case n: code_to_execute_when_value_equals_n break; case m: code_to_execute_when_value_equals_m break; default: code_to_execute_in_all_other_cases }

36 Switch statement example var now = new Date(); var hour = now.gethours(); switch(hour){ } case 9: case 12: case 18: default: document.write( Around nine: coffee time"); break; document.write( Between twelve and one: everyone is gone"); break; document.write( Seventeen?: bring in the caffeine"); break; document.write( Time to work"); Just an extra question: does a switch use == or === for equality? Try it out.

37 Calculator This should also work for operators: -, / and *. When the user chooses a non existing operator the program should show:

38 While statement while(test_that_evaluates_to_true_or_false) { code_to_execute_as_long_as_test_is true //do not forget to change the outcome of the test }

39 While statement example var sum = 0; var n = parseint(prompt( Give number (<0 to stop ); while (n >= 0) { sum = sum + n; n = parseint(prompt( Give number (<0 to stop"); } document.write( The sum equals " + sum);

40 Name is required

41 For statement for(initial;test;change) { code_to_execute } Is the same as Initial while(test) { code_to_execute change }

42 For statement example The following while: var i = 0; while (i < 3){ } console.log(i); i++; Is the same as this for for(var i=0;i<3;i++) { console.log(i); }

43 Arrays Arrays are lists of items var list = [ John, Paul, George, Ringo ]; An item in an array can be accessed by using the index (zero-based): var item = list[0];// John Number of elements: length var n = list.length;//4 Using a for-loop: for (var i=0; i<list.length;i++){ console.log(list[i]); }

44 Simple Array functions Function Description Example indexof(element) join(separator) lastindexof(element) pop() push(element) Returns the position of the first occurence of an element in an Array (not found: -1) Joins the elements into a string. Default separator is comma Returns the position of the last occurence of an element in an Array (not found: -1) Removes the last element of the array and returns it Adds an element to the end of an array and returns the length var l = [ John, Paul, Ringo, George ]; var n = l.indexof( John );//0 var l = [ John, Paul ]; var n=l.join();// John,Paul var l = [ John, Paul, Ringo, George ]; var n = l.lastindexof( John );//0 var l = [ John, Paul ]; var n=l.pop();//n= Paul, l=[ John ]; var l=[ John ]; var n=l.push( Paul );//n=2, l=[ John, Paul ] reverse() Reverse the order of the elements var l=[ John, Paul ]; l.reverse(); //[ Paul, John ] sort() Sorts the element of an array var l=[ Paul, John ]; l.sort();//[ John, Paul ]

45 Example of for and array function <!DOCTYPE html> <html> <head> <title>for+array example</title> <script> var list = []; for (var i=0;i<3;i++) { var name = prompt("give name " + (i+1)); list.push(name); } document.write(list.join(", ")); </script> </head> <body> </body> </html>

46 Create an ordered(ol) list

47 Licence plates What to do when the licence plate was not found?

48 Working with strings Let us start with an example var text = prompt("give some text"); var counter = 0; for (var i=0;i<text.length;i++){ } if (text.charat(i) == 'i') counter ++; document.write( The text contains the character \"i\" " + counter + " times");

49 String functions Function Description Example length charat(position) Returns the number of characters (length is not a function) Returns the character at the specified position(zero based) var text= John ; var n = text.length; //4 var text= John ; var c = text.charat(1): // o includes(text) Returns true when text is part of the string var text= John; var t = text.includes( oh );//true indexof(text) lastindexof(text) slice(start, end) split(separator) Returns the first position of text. (or -1 if text is not found) Returns the last position of text. (or -1 if text is not found) Returns the part of the string that starts at start and ends at end (not included) Splits the string on the separator and returns an array with the substrings var text= Joohn ; var i = text.indexof( o );//1 var text= Joohn ; var i = text.lastindexof( o );//2 var text= John ; var n = text.slice(1, 2);// o var text= John,Paul ; var l = text.split(, );//[ John, Paul ]

50 Draw square (sort of)

51 Functions Blocks of JavaScript code that can be used ( called ) in a script There are existing functions (e.g. document.write(), prompt()) but we can also declare them ourselves function name_of_the_function(arguments_of_the_function) { code_for_the_function } Example function sum(number1, number2) { return number1 + number2; }

52 Calling functions To use a function, we have to call it: alert( Hi all ); To use our sum-function: var result = sum(1,2); function sum(number1, number2) { 3 <= return number1 + number2; } 1 2

53 Example of a function <script> Valid contains </script> var text = prompt("give "); if (isvalid (text)){ document.write(text + " is a valid address."); } else { } document.write(text + " is not a valid address."); function isvalid (mail) { } if (mail.indexof("@") == -1){ } return false; return true; The function returns a boolean => it can be used in if(), while(),

54 Using callback functions A function can take simple types as arguments: number, string, boolean, object But it can also take another function as argument ex.: array function findindex takes as argument a function The function is called for each element of the argument When the function returns true, the iteration stops and the index of that element is returned by findindex

55 Using callback functions E.g. an array var ages = [3, 10, 18, 20]; A callback function: function checkadult(age) { return age >= 18; } ages.findindex(checkadult) will return return 2 (the index of the first element that is greater than or equal to 18)

56 Using callback functions Writing document.write(ages.findindex(checkadult)); is the same as: for(var i=0;i<ages.length;i++){ } if (checkadult(ages[i])){ } document.write(i); break;

57 More elaborate test Continue with the previous example A valid address should only contain John@street@liverpool.ac.uk is not a valid address It must contain text is not a valid address It should also contain at least one dot (.) after Paul@liverpool is also not a valid address Tip: add the tests one at the time

58 Is it a palindrome (e.g. level) <!DOCTYPE html> <html> <head> <title>square</title> <script> var text = prompt("give text"); if (ispalindrome(text)){ document.write(text + " is a palindrome."); } else { document.write(text + " is not a palindrome."); } //write the function here </script> </head> <body> </body> </html> A palindrome is a word that reads the same backward or forward. Add a function to test whether a word is a palindrome.

59 Is it a valid IBAN number There are some calculations involved when we want to check an IBAN number (bank account). We just want to check the form BExx-xxxx-xxxx-xxxx Total length: 19 characters Start with BE 5th, 10th and 15th character must be - Extra: all x s should be digits Write a function in JavaScript to test the form of an IBAN number and use that function in an HTML page.

60 Filter: starting with capital Create a file exfuncfilter.js so that the HTML page shows a comma separated list of all names that start with a capital <!DOCTYPE html> <html> <head> <script> var list = ["John", "paul", "Ringo", "George"]; </script> <script src="exfuncfilter.js"></script> </head> <body> </body> </html>

61 Variable scope A variable that is declared in a function is local var value = 42; dosomething(); console.log(value); // value is still 42 function dosomething() { var value = 2016; }

62 Intermezzo: variable hoisting V2 is undefined because v1 got its value on the next line. Error because v1 does not exist <script> console.dir(window); var v2 = v1; var v1=42; </script> Is there a difference? <script> console.dir(window); var v2 = v1; //var v1 = 42; </script>

63 Intermezzo: variable hoisting Functions will be hoisted before variables => when a function and a variable have the same name (don t ever do this), the function will win because it is declared first. var x; function x(){ console.log("h"); } console.log(typeof x); //function

64 Intermezzo: variable hoisting However, when we initialize the variable, this initialisation will occur after the hoisting and it will overwrite the function var x = 5; function x(){ console.log("h"); } console.log(typeof x); //number

65 Intermezzo: variable hoisting <script> The declaration of a variable is hoisted to the top console.dir(window); var v2 = v1; var v1=42; </script>

66 Intermezzo: variable hoisting <script> var v1; console.dir(window); var v2 = v1; v1=42; </script> On this line v1 is declared but undefined. The declaration of a variable is hoisted to the top

67 Variable scope (EcmaScript 6) Starting with EcmaScript 6 we can have variables in block scope by using let instead of var for declarations. if(true){ let i=7; } console.log(i); // undefined

68 use strict In the past JavaScript was a flexibel (=messy) language We can make it behave more strict using use strict => puts the engine in strict-mode use strict uses quotation marks so that older scripts do not see it as an unknown keyword. use strict works per file or per <script>-element

69 Some consequences of use strict Variables must be declared: x = 42; //not allowed Deleting a variable is not allowed var x = 42; delete x; // not allowed Duplicate argument names are not allowed function DoSomething(arg1, arg1) { // not allowed Writing to a read only property is not allowed var name = John ; name[0] = j ; //not allowed

70 The document object Access the HTML elements in JavaScript => Document Object Model (DOM) <html><head></head><body><ol><li>one</li><li>two</li></ol></body></html> html head Child element Parent element body ol li one Text element li one The DOM-tree

71 The document object Link between DOM-tree (in memory) and JavaScript: the document object <!DOCTYPE html> <html> <head> <title>the document object</title> <script> console.dir(document); </script> </head> <body> </body> </html>

72 Intermezzo: Document Object Model Standard not only used for HTML, also for XML ( Not only used in JavaScript, but also in other languages: Java, PHP, C#, Different levels: level-0 (html soup), level-1, level-2, level-3, level- 4(work in progress) What is the difference between childnodes and children?(both DOM level-1)

73 The document object In HTML every element can have a unique id. JavaScript can get an element based on its id: document.getelementbyid( theid ); ID s are unique => only one element will be returned BUT the element must be available in the DOM-tree

74 The document object <!DOCTYPE html> <html> <head> <title>the document object</title> <script> var elh1 = document.getelementbyid("heading"); console.dir(elh1); </script> </head> <body> <h1 id="heading">title</h1> </body> </html> html head script? Because the h1-element does not exist yet when the JavaScript code is executed, the result of getelementbyid is null (empty)

75 The document object <!DOCTYPE html> <html> <head> <title>the document object</title> </head> <body> <h1 id="heading">title</h1> <script> var elh1 = document.getelementbyid("heading"); console.dir(elh1); </script> </body> </html> html head body h1#heading script Title The h1-element does exist when the JavaScript code is executed, so getelementbyid returns a result

76 The text of an element A text is a childnode But there are also special attributes with which to get the text: textcontent: not supported in IE8, not CSS aware in Firefox (will show hidden text) innertext: CSS aware in Firefox (will not show hidden tekst) innerhtml: all browsers, will include HTML as HTML Solution: jquery text() (cross browser)

77 The text of an element <!DOCTYPE html> <html> <head> <title>copy values</title> </head> <body> <h1 id="heading">title</h1> <div id="body"></div> <script> var elh1 = document.getelementbyid("heading"); var elbody = document.getelementbyid("body"); elbody.textcontent = elh1.textcontent; </script> </body> </html>

78 The value attribute (some) Elements have textnode children The text of an <input>-element is not a textnode <input type= text id= name name= name value= John /> <!DOCTYPE html> <html> <head> <title>value attribute</title> </head> <body> <h1 id="heading">john</h1> <input type="text" id="name" name="name" value="nobody"/> <script> var elh1 = document.getelementbyid("heading"); var elname = document.getelementbyid("name"); elname.value = elh1.textcontent; </script> </body> </html> Quite often attributes can be accessed as properties A more generic way is using setattribute and getattribute. elname.setattribute("value", elh1.textcontent);

79 Buttons <!DOCTYPE html> <html> <head> <title>value attribute</title> </head> <body> <h1 id="heading">john</h1> <input type="submit" id="btn1" /> <button id="btn2"></button> </body> </html> Give both buttons the text of the H1-element

80 Clicking on a button The onclick attribute of a button => execute piece of JavaScript code To define a piece of JavaScript code we use functions function DoSomething(){ alert( Hi all ); } General form: function name(arguments) { code } To execute a function: DoSomething()

81 Clicking on a button <!DOCTYPE html> <html> <head> <title>onclick attribute</title> <script> function SayHi() { } </script> </head> <body> alert("hi all"); <h1 id="heading">john</h1> <button id="btn2" onclick="sayhi();">say hi</button> </body> </html> A function is executed when it is called, not when it is read by the browser JavaScript code to execute the function.

82 Integrating a form with JavaScript <!DOCTYPE html> <html> <head> <title>working with fields</title> <script> function SayHi() { var name = document.getelementbyid("txtname").value; var resultfield = document.getelementbyid("result"); resultfield.textcontent = "Hi " + name; } </script> </head> <body> <form> Name: <input type="text" id="txtname"/> <input type="button" onclick="sayhi();" value="say hi"/> <div id="result"></div> </form> </body> </html>

83 Onclick property vs Onclick attribute Instead of using the HTML onclick attribute we can also use the JavaScript onclick property (compare to: HTML value attribute and JavaScript value property) <body> <form> Name: <input type="text" id="txtname"/> <input id="btn" type="button" value="say hi"/> <div id="result"></div> <script> var btn = document.getelementbyid("btn"); btn.onclick = SayHi; </script> </form> </body>

84 Onclick property vs Onclick attribute Two remarks We have to put the script near the end of the dom-tree. Otherwise document.getelementbyid( btn ) cannot find the button. We do not use the call-operator (two round brackets: SayHi()) Using the call operator like this: btn.onclick = SayHi(); would call the function and store the result in btn.onclick We want to assign the function SayHi to the property onclick

85 Why use btn.onclick instead of < onclick= >? We want to separate the JavaScript code from the HTML code Compare to styles: in most cases you should not use the style attribute in HTML Clear separation between HTML and JavaScript is one of the principles of unobtrusive JavaScript: the site should still work without JavaScript Let us look at an example

86 The obtrusive way This will not work if JavaScript is disabled and there is no way to make it work: <a href="javascript:window.open(' _principles_of_unobtrusive_javascript')">w3c Article</a> The following will work if JavaScript is disabled but it is a maintenance nightmare <a href=" ve_javascript" onclick="window.open(' les_of_unobtrusive_javascript');return false;">w3c Article</a>

87 The unobtrusive way <a class="newwindow" href=" pt">w3c Article</a> <script> var anchors = document.getelementsbyclassname("newwindow"); for (var i=0; i<anchors.length;i++) { anchors[i].onclick = OpenWindow; } function OpenWindow(){ window.open(this.href); return false; } </script> return false: Do not execute the default behavior (=follow link) The keyword this refers to the <a>-element

88 Calculation with select Create a form with two input fields, a drop down (select) field, a button and a span-element. The drop down should contain +, -, * and / When the user fills in two numbers, chooses an operator and clicks the button the result must be shown in the span element

89 Window object In a browser, the window object is the top-level item Everything we declare is stored in this object <!DOCTYPE html> <html> <head> <title>the window object</title> <script> console.dir(window); </script> </head> <body> </body> </html> Console.dir shows the structure of an object.

90 Window object(chrome)

91 Window object <script> </script> var value=42; console.dir(window); We declare a variabele here Every variable we declare becomes an item in the window object.

CSC Web Programming. Introduction to JavaScript

CSC 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 information

JavaScript CS 4640 Programming Languages for Web Applications

JavaScript 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 information

JavaScript CS 4640 Programming Languages for Web Applications

JavaScript 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 information

JavaScript 2. Jef De Smedt Beta VZW

JavaScript 2. Jef De Smedt Beta VZW JavaScript 2 Jef De Smedt Beta VZW Overview Introduction Basic elements of JavaScript Arrays Window object Document Object Model Forms Events Objects Recap JavaScript is a scripting language that is browser

More information

Background. Javascript is not related to Java in anyway other than trying to get some free publicity

Background. Javascript is not related to Java in anyway other than trying to get some free publicity JavaScript I Introduction JavaScript traditionally runs in an interpreter that is part of a browsers Often called a JavaScript engine Was originally designed to add interactive elements to HTML pages First

More information

CGS 3066: Spring 2015 JavaScript Reference

CGS 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 information

COMS 469: Interactive Media II

COMS 469: Interactive Media II COMS 469: Interactive Media II Agenda Review Data Types & Variables Decisions, Loops, and Functions Review gunkelweb.com/coms469 Review Basic Terminology Computer Languages Interpreted vs. Compiled Client

More information

Client-Side Web Technologies. JavaScript Part I

Client-Side Web Technologies. JavaScript Part I Client-Side Web Technologies JavaScript Part I JavaScript First appeared in 1996 in Netscape Navigator Main purpose was to handle input validation that was currently being done server-side Now a powerful

More information

Lecture 8 (7.5?): Javascript

Lecture 8 (7.5?): Javascript Lecture 8 (7.5?): Javascript Dynamic web interfaces forms are a limited interface

More information

FALL 2017 CS 498RK JAVASCRIPT. Fashionable and Functional!

FALL 2017 CS 498RK JAVASCRIPT. Fashionable and Functional! CS 498RK FALL 2017 JAVASCRIPT Fashionable and Functional! JAVASCRIPT popular scripting language on the Web, supported by browsers separate scripting from structure (HTML) and presentation (CSS) client-

More information

Web Site Design and Development JavaScript

Web Site Design and Development JavaScript Web Site Design and Development JavaScript CS 0134 Fall 2018 Tues and Thurs 1:00 2:15PM JavaScript JavaScript is a programming language that was designed to run in your web browser. 2 Some Definitions

More information

5. Strict mode use strict ; 6. Statement without semicolon, with semicolon 7. Keywords 8. Variables var keyword and global scope variable 9.

5. Strict mode use strict ; 6. Statement without semicolon, with semicolon 7. Keywords 8. Variables var keyword and global scope variable 9. Javascript 1) Javascript Implementation 1. The Core(ECMAScript) 2. DOM 3. BOM 2) ECMAScript describes 1. Syntax 2. Types 3. Statements 4. Keywords 5. Reserved words 6. Operators 7. Objects 3) DOM 1. Tree

More information

Client vs Server Scripting

Client 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 information

Outline. Introduction to JavaScript Resources What is JavaScript? JavaScript in web pages

Outline. Introduction to JavaScript Resources What is JavaScript? JavaScript in web pages JavaScript CMPT 281 Outline Introduction to JavaScript Resources What is JavaScript? JavaScript in web pages Announcements Layout with tables Assignment 3 JavaScript Resources Resources Why JavaScript?

More information

E ECMAScript, 21 elements collection, HTML, 30 31, 31. Index 161

E 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 information

Chapter 3 - Simple JavaScript - Programming Basics. Lesson 1 - JavaScript: What is it and what does it look like?

Chapter 3 - Simple JavaScript - Programming Basics. Lesson 1 - JavaScript: What is it and what does it look like? Chapter 3 - Simple JavaScript - Programming Basics Lesson 1 - JavaScript: What is it and what does it look like? PP presentation JavaScript.ppt. Lab 3.1. Lesson 2 - JavaScript Comments, document.write(),

More information

JavaScript Lecture 1

JavaScript Lecture 1 JavaScript Lecture 1 Waterford Institute of Technology May 17, 2016 John Fitzgerald Waterford Institute of Technology, JavaScriptLecture 1 1/31 Javascript Extent of this course A condensed basic JavaScript

More information

Web 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 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 information

JavaScript I Language Basics

JavaScript I Language Basics JavaScript I Language Basics Chesapeake Node.js User Group (CNUG) https://www.meetup.com/chesapeake-region-nodejs-developers-group START BUILDING: CALLFORCODE.ORG Agenda Introduction to JavaScript Language

More information

Client Side JavaScript and AJAX

Client Side JavaScript and AJAX Client Side JavaScript and AJAX Client side javascript is JavaScript that runs in the browsers of people using your site. So far all the JavaScript code we've written runs on our node.js server. This is

More information

JavaScript: Introduction, Types

JavaScript: 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 information

COMP284 Scripting Languages Lecture 14: JavaScript (Part 1) Handouts

COMP284 Scripting Languages Lecture 14: JavaScript (Part 1) Handouts COMP284 Scripting Languages Lecture 14: JavaScript (Part 1) Handouts Ullrich Hustadt Department of Computer Science School of Electrical Engineering, Electronics, and Computer Science University of Liverpool

More information

JavaScript: The Basics

JavaScript: The Basics JavaScript: The Basics CISC 282 October 4, 2017 JavaScript A programming language "Lightweight" and versatile Not universally respected Appreciated in the web domain Adds programmatic functionality to

More information

Princess Nourah bint Abdulrahman University. Computer Sciences Department

Princess Nourah bint Abdulrahman University. Computer Sciences Department Princess Nourah bint Abdulrahman University 1 And use http://www.w3schools.com/ JavaScript Objectives Introduction to JavaScript Objects Data Variables Operators Types Functions Events 4 Why Study JavaScript?

More information

Session 3: JavaScript - Structured Programming

Session 3: JavaScript - Structured Programming INFM 603: Information Technology and Organizational Context Session 3: JavaScript - Structured Programming Jimmy Lin The ischool University of Maryland Thursday, September 25, 2014 Source: Wikipedia Types

More information

HTML5 and CSS3 More JavaScript Page 1

HTML5 and CSS3 More JavaScript Page 1 HTML5 and CSS3 More JavaScript Page 1 1 HTML5 and CSS3 MORE JAVASCRIPT 3 4 6 7 9 The Math Object The Math object lets the programmer perform built-in mathematical tasks Includes several mathematical methods

More information

JavaScript Introduction

JavaScript 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 information

JavaScript Specialist v2.0 Exam 1D0-735

JavaScript 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 information

COMS 469: Interactive Media II

COMS 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 information

The course is supplemented by numerous hands-on labs that help attendees reinforce their theoretical knowledge of the learned material.

The course is supplemented by numerous hands-on labs that help attendees reinforce their theoretical knowledge of the learned material. Lincoln Land Community College Capital City Training Center 130 West Mason Springfield, IL 62702 217-782-7436 www.llcc.edu/cctc WA2442 Introduction to JavaScript Objectives This intensive training course

More information

Part 1: jquery & History of DOM Scripting

Part 1: jquery & History of DOM Scripting Karl Swedberg: Intro to JavaScript & jquery 0:00:00 0:05:00 0:05:01 0:10:15 0:10:16 0:12:36 0:12:37 0:13:32 0:13:32 0:14:16 0:14:17 0:15:42 0:15:43 0:16:59 0:17:00 0:17:58 Part 1: jquery & History of DOM

More information

A.A. 2008/09. Why introduce JavaScript. G. Cecchetti Internet Software Technologies

A.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 information

Working with JavaScript

Working with JavaScript Working with JavaScript Creating a Programmable Web Page for North Pole Novelties 1 Objectives Introducing JavaScript Inserting JavaScript into a Web Page File Writing Output to the Web Page 2 Objectives

More information

Variables and Typing

Variables and Typing Variables and Typing Christopher M. Harden Contents 1 The basic workflow 2 2 Variables 3 2.1 Declaring a variable........................ 3 2.2 Assigning to a variable...................... 4 2.3 Other

More information

COMS W3101: SCRIPTING LANGUAGES: JAVASCRIPT (FALL 2017)

COMS 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 information

HTML 5 and CSS 3, Illustrated Complete. Unit L: Programming Web Pages with JavaScript

HTML 5 and CSS 3, Illustrated Complete. Unit L: Programming Web Pages with JavaScript HTML 5 and CSS 3, Illustrated Complete Unit L: Programming Web Pages with JavaScript Objectives Explore the Document Object Model Add content using a script Trigger a script using an event handler Create

More information

React. HTML code is made up of tags. In the example below, <head> is an opening tag and </head> is the matching closing tag.

React. HTML code is made up of tags. In the example below, <head> is an opening tag and </head> is the matching closing tag. Document Object Model (DOM) HTML code is made up of tags. In the example below, is an opening tag and is the matching closing tag. hello The tags have a tree-like

More information

A Balanced Introduction to Computer Science, 3/E

A Balanced Introduction to Computer Science, 3/E A Balanced Introduction to Computer Science, 3/E David Reed, Creighton University 2011 Pearson Prentice Hall ISBN 978-0-13-216675-1 Chapter 4 JavaScript and Dynamic Web Pages 1 Static vs. Dynamic Pages

More information

JavaScript. What s wrong with JavaScript?

JavaScript. 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 information

This course is designed for web developers that want to learn HTML5, CSS3, JavaScript and jquery.

This 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 information

Boot Camp JavaScript Sioux, March 31, 2011

Boot Camp JavaScript  Sioux, March 31, 2011 Boot Camp JavaScript http://rix0r.nl/bootcamp Sioux, March 31, 2011 Agenda Part 1: JavaScript the Language Short break Part 2: JavaScript in the Browser History May 1995 LiveScript is written by Brendan

More information

INF5750. Introduction to JavaScript and Node.js

INF5750. Introduction to JavaScript and Node.js INF5750 Introduction to JavaScript and Node.js Outline Introduction to JavaScript Language basics Introduction to Node.js Tips and tools for working with JS and Node.js What is JavaScript? Built as scripting

More information

JavaScript. History. Adding JavaScript to a page. CS144: Web Applications

JavaScript. History. Adding JavaScript to a page. CS144: Web Applications JavaScript Started as a simple script in a Web page that is interpreted and run by the browser Supported by most modern browsers Allows dynamic update of a web page More generally, allows running an arbitrary

More information

JavaScript: Introductionto Scripting

JavaScript: Introductionto Scripting 6 Comment is free, but facts are sacred. C. P. Scott The creditor hath a better memory than the debtor. James Howell When faced with a decision, I always ask, What would be the most fun? Peggy Walker Equality,

More information

JavaScript. History. Adding JavaScript to a page. CS144: Web Applications

JavaScript. History. Adding JavaScript to a page. CS144: Web Applications JavaScript Started as a simple script in a Web page that is interpreted and run by the browser Supported by most modern browsers Allows dynamic update of a web page More generally, allows running an arbitrary

More information

CSI 3140 WWW Structures, Techniques and Standards. Browsers and the DOM

CSI 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 information

3 The Building Blocks: Data Types, Literals, and Variables

3 The Building Blocks: Data Types, Literals, and Variables chapter 3 The Building Blocks: Data Types, Literals, and Variables 3.1 Data Types A program can do many things, including calculations, sorting names, preparing phone lists, displaying images, validating

More information

JavaScript. The Bad Parts. Patrick Behr

JavaScript. The Bad Parts. Patrick Behr JavaScript The Bad Parts Patrick Behr History Created in 1995 by Netscape Originally called Mocha, then LiveScript, then JavaScript It s not related to Java ECMAScript is the official name Many implementations

More information

Chapter 1 Introduction to Computers and the Internet

Chapter 1 Introduction to Computers and the Internet CPET 499/ITC 250 Web Systems Dec. 6, 2012 Review of Courses Chapter 1 Introduction to Computers and the Internet The Internet in Industry & Research o E Commerce & Business o Mobile Computing and SmartPhone

More information

JScript Reference. Contents

JScript Reference. Contents JScript Reference Contents Exploring the JScript Language JScript Example Altium Designer and Borland Delphi Run Time Libraries Server Processes JScript Source Files PRJSCR, JS and DFM files About JScript

More information

What is Java Script? Writing to The HTML Document. What Can JavaScript do? CMPT 165: Java Script

What is Java Script? Writing to The HTML Document. What Can JavaScript do? CMPT 165: Java Script What is Java Script? CMPT 165: Java Script Tamara Smyth, tamaras@cs.sfu.ca School of Computing Science, Simon Fraser University November 7, 2011 JavaScript was designed to add interactivity to HTML pages

More information

Introduction to JavaScript p. 1 JavaScript Myths p. 2 Versions of JavaScript p. 2 Client-Side JavaScript p. 3 JavaScript in Other Contexts p.

Introduction 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 information

8/19/2018. Web Development & Design Foundations with HTML5. Learning Objectives (1 of 2) Learning Objectives (2 of 2) What is JavaScript?

8/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 information

welcome to BOILERCAMP HOW TO WEB DEV

welcome to BOILERCAMP HOW TO WEB DEV welcome to BOILERCAMP HOW TO WEB DEV Introduction / Project Overview The Plan Personal Website/Blog Schedule Introduction / Project Overview HTML / CSS Client-side JavaScript Lunch Node.js / Express.js

More information

Manju Muralidharan Priya. CS4PM Web Aesthetics and Development WEEK 11

Manju Muralidharan Priya. CS4PM Web Aesthetics and Development WEEK 11 CS4PM Web Aesthetics and Development WEEK 11 Objective: Understand basics of JScript Outline: a. Basics of JScript Reading: Refer to w3schools websites and use the TRY IT YOURSELF editor and play with

More information

5. JavaScript Basics

5. JavaScript Basics CHAPTER 5: JavaScript Basics 88 5. JavaScript Basics 5.1 An Introduction to JavaScript A Programming language for creating active user interface on Web pages JavaScript script is added in an HTML page,

More information

Elementary Computing CSC 100. M. Cheng, Computer Science

Elementary Computing CSC 100. M. Cheng, Computer Science Elementary Computing CSC 100 1 Basic Programming Concepts A computer is a kind of universal machine. By using different software, a computer can do different things. A program is a sequence of instructions

More information

Session 6. JavaScript Part 1. Reading

Session 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 information

INTRODUCTION TO JAVASCRIPT

INTRODUCTION 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 information

Module 5 JavaScript, AJAX, and jquery. Module 5. Module 5 Contains 2 components

Module 5 JavaScript, AJAX, and jquery. Module 5. Module 5 Contains 2 components Module 5 JavaScript, AJAX, and jquery Module 5 Contains 2 components Both the Individual and Group portion are due on Monday October 30 th Start early on this module One of the most time consuming modules

More information

Programming language components

Programming language components Programming language components syntax: grammar rules for defining legal statements what's grammatically legal? how are things built up from smaller things? semantics: what things mean what do they compute?

More information

Web Development. HCID 520 User Interface Software & Technology

Web Development. HCID 520 User Interface Software & Technology Web Development! HCID 520 User Interface Software & Technology Web Browser Timeline 1993: NCSA Mosaic web browser First broadly adopted graphical browser URL bar, back/forward buttons, images, etc Creators

More information

710 Index Attributes, 127 action attribute, 263 assigning, bottom attribute, domain name attribute, 481 expiration date attribute, 480 8

710 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 information

Tutorial 10: Programming with JavaScript

Tutorial 10: Programming with JavaScript Tutorial 10: Programming with JavaScript College of Computing & Information Technology King Abdulaziz University CPCS-665 Internet Technology Objectives Learn the history of JavaScript Create a script

More information

c122mar413.notebook March 06, 2013

c122mar413.notebook March 06, 2013 These are the programs I am going to cover today. 1 2 Javascript is embedded in HTML. The document.write() will write the literal Hello World! to the web page document. Then the alert() puts out a pop

More information

<form>. input elements. </form>

<form>. input elements. </form> CS 183 4/8/2010 A form is an area that can contain form elements. Form elements are elements that allow the user to enter information (like text fields, text area fields, drop-down menus, radio buttons,

More information

JavaScript s role on the Web

JavaScript 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 information

JAVASCRIPT. The Basics

JAVASCRIPT. The Basics JAVASCRIPT The Basics WHAT TO EXPECT 1. What is JavaScript? 2. Data Types and Variables - Variables, Strings & Booleans 3. Arrays 4. Objects 5. Conditionals and Loops 6. jquery 7. Hangman Time! Content

More information

Javascript. Many examples from Kyle Simpson: Scope and Closures

Javascript. 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 information

JAVASCRIPT AND JQUERY: AN INTRODUCTION (WEB PROGRAMMING, X452.1)

JAVASCRIPT AND JQUERY: AN INTRODUCTION (WEB PROGRAMMING, X452.1) Technology & Information Management Instructor: Michael Kremer, Ph.D. Class 1 Professional Program: Data Administration and Management JAVASCRIPT AND JQUERY: AN INTRODUCTION (WEB PROGRAMMING, X452.1) WHO

More information

CS312: Programming Languages. Lecture 21: JavaScript

CS312: Programming Languages. Lecture 21: JavaScript CS312: Programming Languages Lecture 21: JavaScript Thomas Dillig Thomas Dillig, CS312: Programming Languages Lecture 21: JavaScript 1/25 Why Discuss JavaScript? JavaScript is very widely used and growing

More information

Why Discuss JavaScript? CS312: Programming Languages. Lecture 21: JavaScript. JavaScript Target. What s a Scripting Language?

Why Discuss JavaScript? CS312: Programming Languages. Lecture 21: JavaScript. JavaScript Target. What s a Scripting Language? Why Discuss JavaScript? CS312: Programming Languages Lecture 21: JavaScript Thomas Dillig JavaScript is very widely used and growing Any AJAX application heavily relies on JavaScript JavaScript also has

More information

What is PHP? [1] Figure 1 [1]

What is PHP? [1] Figure 1 [1] PHP What is PHP? [1] PHP is an acronym for "PHP: Hypertext Preprocessor" PHP is a widely-used, open source scripting language PHP scripts are executed on the server PHP is free to download and use Figure

More information

Chapter 9: Simple JavaScript

Chapter 9: Simple JavaScript Chapter 9: Simple JavaScript Learning Outcomes: Identify the benefits and uses of JavaScript Identify the key components of the JavaScript language, including selection, iteration, variables, functions

More information

ORB Education Quality Teaching Resources

ORB Education Quality Teaching Resources JavaScript is one of the programming languages that make things happen in a web page. It is a fantastic way for students to get to grips with some of the basics of programming, whilst opening the door

More information

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:

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: 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 information

Web Programming/Scripting: JavaScript

Web 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 information

Documents and computation. Introduction to JavaScript. JavaScript vs. Java Applet. Myths. JavaScript. Standard

Documents and computation. Introduction to JavaScript. JavaScript vs. Java Applet. Myths. JavaScript. Standard Introduction to Prof. Ing. Andrea Omicini II Facoltà di Ingegneria, Cesena Alma Mater Studiorum, Università di Bologna andrea.omicini@unibo.it Documents and computation HTML Language for the description

More information

At the Forge JavaScript Reuven M. Lerner Abstract Like the language or hate it, JavaScript and Ajax finally give life to the Web. About 18 months ago, Web developers started talking about Ajax. No, we

More information

jquery and AJAX

jquery and AJAX jquery and AJAX http://www.flickr.com/photos/pmarkham/3165964414/ Dynamic HTML (DHTML) Manipulating the web page's structure is essential for creating a highly responsive UI Two main approaches Manipulate

More information

JavaScript By: A. Mousavi & P. Broomhead SERG, School of Engineering Design, Brunel University, UK

JavaScript By: A. Mousavi & P. Broomhead SERG, School of Engineering Design, Brunel University, UK Programming for Digital Media EE1707 JavaScript By: A. Mousavi & P. Broomhead SERG, School of Engineering Design, Brunel University, UK 1 References and Sources 1. Javascript & JQuery: interactive front-end

More information

Enhancing Web Pages with JavaScript

Enhancing Web Pages with JavaScript Enhancing Web Pages with JavaScript Introduction In this Tour we will cover: o The basic concepts of programming o How those concepts are translated into JavaScript o How JavaScript can be used to enhance

More information

JavaScript: the Big Picture

JavaScript: the Big Picture JavaScript had to look like Java only less so be Java's dumb kid brother or boy-hostage sidekick. Plus, I had to be done in ten days or something worse than JavaScript would have happened.! JavaScript:

More information

INFS 2150 Introduction to Web Development and e-commerce Technology. Programming with JavaScript

INFS 2150 Introduction to Web Development and e-commerce Technology. Programming with JavaScript INFS 2150 Introduction to Web Development and e-commerce Technology Programming with JavaScript 1 Objectives JavaScript client-side programming Example of a JavaScript program The element

More information

Objectives. Introduction to JavaScript. Introduction to JavaScript INFS Peter Y. Wu, RMU 1

Objectives. Introduction to JavaScript. Introduction to JavaScript INFS Peter Y. Wu, RMU 1 Objectives INFS 2150 Introduction to Web Development and e-commerce Technology Programming with JavaScript JavaScript client-side programming Example of a JavaScript program The element

More information

<body> <form id="myform" name="myform"> <!-- form child elements go in here --> </form> </body>

<body> <form id=myform name=myform> <!-- form child elements go in here --> </form> </body> ITEC 136 Business Programming Concepts Week 08, Part 01 Overview 1 Week 7 Review Sentinel controlled loops Results controlled loops Flag controlled loops break and continue keywords Nested loops Loop variable

More information

CIS 228 (Spring, 2012) Final, 5/17/12

CIS 228 (Spring, 2012) Final, 5/17/12 CIS 228 (Spring, 2012) Final, 5/17/12 Name (sign) Name (print) email I would prefer to fail than to receive a grade of or lower for this class. Question 1 2 3 4 5 6 7 8 9 A B C D E TOTAL Score CIS 228,

More information

IN Development in Platform Ecosystems Lecture 2: HTML, CSS, JavaScript

IN Development in Platform Ecosystems Lecture 2: HTML, CSS, JavaScript IN5320 - Development in Platform Ecosystems Lecture 2: HTML, CSS, JavaScript 27th of August 2018 Department of Informatics, University of Oslo Magnus Li - magl@ifi.uio.no 1 Today s lecture 1. 2. 3. 4.

More information

age = 23 age = age + 1 data types Integers Floating-point numbers Strings Booleans loosely typed age = In my 20s

age = 23 age = age + 1 data types Integers Floating-point numbers Strings Booleans loosely typed age = In my 20s Intro to Python Python Getting increasingly more common Designed to have intuitive and lightweight syntax In this class, we will be using Python 3.x Python 2.x is still very popular, and the differences

More information

CISC 1600 Lecture 2.4 Introduction to JavaScript

CISC 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 information

Course Outline. Introduction to java

Course Outline. Introduction to java Course Outline 1. Introduction to OO programming 2. Language Basics Syntax and Semantics 3. Algorithms, stepwise refinements. 4. Quiz/Assignment ( 5. Repetitions (for loops) 6. Writing simple classes 7.

More information

SEEM4570 System Design and Implementation Lecture 03 JavaScript

SEEM4570 System Design and Implementation Lecture 03 JavaScript SEEM4570 System Design and Implementation Lecture 03 JavaScript JavaScript (JS)! Developed by Netscape! A cross platform script language! Mainly used in web environment! Run programs on browsers (HTML

More information

CMPT 100 : INTRODUCTION TO

CMPT 100 : INTRODUCTION TO CMPT 100 : INTRODUCTION TO COMPUTING TUTORIAL #5 : JAVASCRIPT 2 GUESSING GAME 1 By Wendy Sharpe BEFORE WE GET STARTED... If you have not been to the first tutorial introduction JavaScript then you must

More information

People = End Users & Programmers. The Web Browser Application. Program Design Phase. Algorithm Design -Mathematical Y = MX + B

People = End Users & Programmers. The Web Browser Application. Program Design Phase. Algorithm Design -Mathematical Y = MX + B The Web Browser Application People = End Users & Programmers Clients and Components Input from mouse and keyboard Controller HTTP Client FTP Client TCP/IP Network Interface HTML/XHTML CSS JavaScript Flash

More information

CSC Javascript

CSC Javascript CSC 4800 Javascript See book! Javascript Syntax How to embed javascript between from an external file In an event handler URL - bookmarklet

More information

JAVASCRIPT. sarojpandey.com.np/iroz. JavaScript

JAVASCRIPT. sarojpandey.com.np/iroz. JavaScript JAVASCRIPT 1 Introduction JAVASCRIPT is a compact, object-based scripting language for developing client Internet applications. was designed to add interactivity to HTML pages. is a scripting language

More information

CMPT 125: Lecture 3 Data and Expressions

CMPT 125: Lecture 3 Data and Expressions CMPT 125: Lecture 3 Data and Expressions Tamara Smyth, tamaras@cs.sfu.ca School of Computing Science, Simon Fraser University January 3, 2009 1 Character Strings A character string is an object in Java,

More information

Frontend II: Javascript and DOM Programming. Wednesday, January 7, 15

Frontend II: Javascript and DOM Programming. Wednesday, January 7, 15 6.148 Frontend II: Javascript and DOM Programming Let s talk about Javascript :) Why Javascript? Designed in ten days in December 1995! How are they similar? Javascript is to Java as hamster is to ham

More information

BEFORE CLASS. If you haven t already installed the Firebug extension for Firefox, download it now from

BEFORE CLASS. If you haven t already installed the Firebug extension for Firefox, download it now from BEFORE CLASS If you haven t already installed the Firebug extension for Firefox, download it now from http://getfirebug.com. If you don t already have the Firebug extension for Firefox, Safari, or Google

More information

Web Development & Design Foundations with HTML5, 8 th Edition Instructor Materials Chapter 14 Test Bank

Web 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 information