Unit 20 - Client Side Customisation of Web Pages. Week 4 Lesson 5 Fundamentals of Scripting

Size: px
Start display at page:

Download "Unit 20 - Client Side Customisation of Web Pages. Week 4 Lesson 5 Fundamentals of Scripting"

Transcription

1 Unit 20 - Client Side Customisation of Web Pages Week 4 Lesson 5 Fundamentals of Scripting

2 The story so far... three methods of writing CSS: In-line Embedded }These are sometimes called External } block methods all the CSS is blocked together. The CSS Box model Positioning

3 Fundamentals of Scripting Languages What a scripting language is How it works What types are available The main features How does a scripting language improve functionality Explain in detail how a browser implements a scripting language

4 Fundamentals of Scripting Languages Characteristics of scripting languages: Uses of a scripting language: Scripting language constructs:

5 Characteristics of scripting languages nature of language eg object oriented, event driven; objects; methods; handling events; hiding scripts; security issues eg reading, writing, client files, opening/closing user windows, reading information; including scripts inside HTML

6 Introduction Find definitions for the following terms: Interactivity Static website Dynamic website Interpret Go live Name some scripting languages.

7 Characterisitics Type of language Hiding scripts from older browsers Security issues Including scripts inside HTML

8 A snippet of code... <html> <head> <script> This is where the scripting language would be written. </script> </head> <body>lorem ipsum</body> </html>

9 Types of Scripting Language 2 modes of operation Event-driven Object-oriented Write a brief description of each. Include examples of each mode.

10 Types Object Oriented Code broken into Objects Self-contained modules Knows about itself Knows what it can do Knows what it can interact with Eg VBScript Event driven Code broken into Events Code is triggered when actions occur: Mouse click Key press Movement Transmission of data Eg Javascript

11 Older browsers May not support scripts Need to hide the script to avoid confusion Put the script within HTML comments <script> <!-- script code written here //--!> </script>

12 Security Scripts are executed on the clients PC Entry point for hackers Makes both client and website vulnerable Website owners (if unscrupulous) could also take advantage and read client s PC eg data-mining or reading other browser windows What law attempts to control this?

13 Uses of scripting language To provide interactivity. Interactivity 2-way communication between human and computer

14 Uses of scripting language To provide interactivity. You will need to include 3 different interactivities in your website later in this unit. What examples can you find? Find at least 5 different interactivities now. Reference the URLs Can you find the scripts which run these interactivities?

15 Uses of scripting language To provide interactivity. Alerts (pop-ups) Prompts and confirmation of choices Checking/validating input Handling forms Redirecting Rollover buttons Browser detection Cookies installing and maintaining

16 Designing interactivities For your website you must design interactivities. To do this you should use: Pseudo-code Flow diagrams

17 Pseudo code Code but not code Pseudo Code Age=input from user If age +> 18 then print onscreen I am an adult Else Print onscreen I am x years old JavaScript Age=prompt( Enter age, ); If (age>=18) {document.write( I am an adult );} Else {document.write( I am + age + years old );}

18 Flow diagram Input age Is user >=18? No I am x years old yes I am an adult

19 Design task Refer to two (or more) of the interactivities you previously discovered. Create a design for each using: Pseudo code Flow diagram

20 Scripting language constructs syntax eg dot operator, values, variables, operators, assignment, comparisons; methods eg write(), click(), open(), selected(); properties eg name, width, ID, value loops eg for, for/in, do/while; decision making eg if, if/else, switch/case; functions (calling, parameter passing); handling events eg onfocus, onload, onblur, onmouseover;

21 Constructs Need correct construction: Syntax i.e. Grammar and order correct of words Dot operator allows an object to use a method Variable data stored as text or numbers Must have unique name within script Loops or iterations code which is executed repeatedly.

22 The maths bit Often need calculations within a script, valid operators include: + plus - minus * multiply / divide > greater than < less than ++ increment by 1 -- decrement by 1 == checks if equal >= equal to or less than!= not equal

23 Loops Or iterations Code which is executed repeatedly until preset condition is met Condition is set either at end or start of code Actions are defined in {curly brackets} Different types producing different effects

24 Loops for - loops through a block of code a specified number of times while - loops through a block of code while a specified condition is true do...while - also loops through a block of code while a specified condition is true for...in - loops through the properties of an object

25 Loop example <script> For (count = 0; count <= 5; count++) {document.write( The number is + count) Document. Write( <br> )//uses html within script} </script>

26 Loop example (for/in) <script> Numbers = new Array() Numbers [0] = zero Numbers [1] = one Numbers [2] = two For (x in numbers) { document.write ( The number is + numbers [x]) Document.write( <br> )} </script>

27 Loop example (while) <script> Count = 0 While (count <= 5) { document.write( The number is + count) Document.write( <br> ) Count ++ } </script>

28 Playing with loops Break - breaks the loop and continue executing the code that follows after the loop (if any). Continue - breaks the iteration and continues with the next value.

29 Break example for (i=0;i<10;i++) { if (i==3) { break; } x=x + "The number is " + i + "<br />"; }

30 continue for (i=0;i<=10;i++) { if (i==3) { continue; } x=x + "The number is " + i + "<br />"; }

31 Loops for while for in break continue

32 Task Find or create an example of a loop there may be one in one of the interactivities you discovered earlier. Record this you will need it for the assignment

33 Dot operator <script> Str= first message 1. Document.write(str.replace(/first/, second )) </script> Object string uses the method replace Hw = Hello world 1. Document.write(hw.length) These constructs are nearly right; nearly right doesn t work, can you correct them? 2. Document.write(hw.toUpperCase()

34 Variables A way of storing data (e.g.text or numbers) Must have a unique name within script Names cannot contain spaces Names cannot start with a number Should be meaningful for editing Can be assigned a value (initial data) Collection of variables can be stored in an array Array should be named and each item numbered (starting with 0)

35 Turnip array <html> <head> <script> product_name="turnip" quantity=50 </script> </head> <body> <script> Veg Turnip carrot spinach celery cabbage document.write (product_name, ("<br>"), quantity) </script> </body> </html>

36 Array_1 var vegetables= new Array(5) vegetables["turnip"]= "50"; vegetables["carrot"]= 10; vegetables["spinach"]= 20; vegetables["celery"]= 30 ; vegetables["cabbage"]= 1; </script> <head> <body>

37 As a table <script> document.write("<table border=\"1\" cellpadding=\"5\">"); document.write("<tr><th>veg</th><th>quantity</th></tr>"); //Now we start the for loop using the variable vegetable to hold our key. for ( var vegetable in vegetables) //print the values into a table cell for each iteration document.write( "<tr><td>" + vegetable + "</td><td>" + vegetables[vegetable] + "</td></tr>"); //finally close the table document.write ("</table>");

38 Horizontal table 1 <script>document.write("<table border=\"1\" cellpadding=\"5\">");document.write("<tr>< th>veg</th>");//now we start the for loop using the variable vegetable to hold our key.for ( var vegetable in vegetables) //print the values into a table cell for each iteration on top row document.write("<td>" + vegetable + "</td>")</script>

39 Horizontal table 2 <script>document.write ("</tr><tr><th>quantity</th>"); //close top row, start second row for ( var vegetable in vegetables) //print the values into a table cell for each iteration, bottom row document.write ("<td>" + vegetables[vegetable] + "</td>"); //finally close the table document.write ("</tr></table>"); </script>

40 Array with Maths Using the vegetable array: Create functions to change the stock level depending on user activity. E.g. Stock check to see if the correct number of turnips (50) are present == Adjust stock level because of sales -- Adjust stock level because of purchases + Alarm when less than a certain number

41 Objects A type of data which: Knows things about itself (properties) Knows how to do things (methods) Many objects already exist Can create new ones

42 An example of object code... The String object: <script> Hw= Hello World document.write(hw.length) </script>

43 Methods Each object knows which methods it can carry out, eg (string object): <script> Hw= Hello world document.write(hw.touppercase()) </Script> Copy this code and observe the screen output.

44 Methods A method is an action which can be performed by an object <html> <body> <script type="text/vbscript"> document.write("<h1>hello World!</h1>") </script> </body> </html>

45 Methods The properties of an object may change as a result of a method being carried out. There are several preset objects each with predefined methods:.write display information.click simulate a click.value take the value from an input.open loads a page in a new browser window.selectedindex shows which option from a drop-down list has been selected

46 Useful tools Firefox add-ons: Web-dev firebug

47 Fundamentals of Scripting Languages What is a scripting language? How does it work? What types are available? How does a scripting language improve functionality? Explain in detail how a browser implements a scripting language

48 Reminder L3U20A1 revision Due 17 th April next Sunday

49 Functions function functionname() { some code }

50 Simple alert function 1. <!DOCTYPE html> <html> <head> <script> function myfunction() { alert("hello World!"); } </script> </head> <body> <button onclick="myfunction()">try it</button> </body> </html>

51 arguments Values that are passed along with a function (also called parameters) can be used inside the function. You can send as many arguments as you like, separated by commas (,) Declare the variables when you name the function; must be kept in expected order function myfunction(var1,var2) { some code }

52 Example of arguments <button onclick="myfunction('harry Potter','Wizard')">Try it</button> <script> function myfunction(name,job) { alert("welcome " + name + ", the " + job); } </script> Note how name and job are kept in the expected order. <button onclick="myfunction('harry Potter','Wizard')">Try it</button> <button onclick="myfunction('bob', Lecturer')">Try it</button>

53 Return values return a value back to where the call was made the function will stop executing, and return the specified value.

54 Decision making Script can be used to make decisions automatically. if if else Switch...case

55 if statement Note that if is written in lowercase letters. Using uppercase letters (IF) will generate a JavaScript error. <script> function myfunction() { var time = new Date().getHours(); if (time < 20) {

56 if statement document.getelementbyid("demo").innerh TML = "Good day"; } } </script>

57 <p>click the button to display "Good day", only if the time is less than 20:00.</p> <button onclick="myfunction()">try it</button> <p id="demo"></p>

58 if (time<20) { x="good day"; } else { x="good evening"; } If else

59 If else if else if (condition1) { code to be executed if condition1 is true } else if (condition2) { code to be executed if condition2 is true } else { code to be executed if neither condition1 nor condition2 is true }

60 Switch example Use the switch statement to select one of many blocks of code to be executed. switch(n) { case 1: execute code block 1 break; case 2: execute code block 2 break; default: code to be executed if n is different from case 1 and 2 }

61 Default Use the default keyword to specify what to do if there is no match: var day=new Date().getDay(); switch (day) { case 6: x="today it's Saturday"; break; case 0: x="today it's Sunday"; break; default: x="looking forward to the Weekend"; }

62 Boxes Alert box Confirm box Prompt box

63 alert <!DOCTYPE html> <html> <head> <script> function myfunction() { alert("i am an alert box!"); } </script> </head> <body> <input type="button" onclick="myfunction()" value="show alert box" /> </body> </html>

64 confirm var r=confirm("press a button"); if (r==true) { x="you pressed OK!"; } else { x="you pressed Cancel!"; }

65 prompt used if you want the user to input a value before entering a page. the user will have to enter an input value the user will have to click either "OK" or "Cancel" to proceed If the user clicks "OK" the box returns the input value. If the user clicks "Cancel" the box returns null. var name=prompt("please enter your name","harry Potter"); if (name!=null && name!="") { x="hello " + name + "! How are you today?"; }

66 Function example <html> <head> <title> Function example </title> <script> Function details() { // insert your new code here } </script> </head> <body> </body> </html>

67 Function example... After the body tag insert: <b> Methods example Page</b> <br> <form name= DetailsForm > Enter full name <input type = text name= fullname ><br> Gender: <select id=gender> <option>male</option> <option>female</option> </select></br> <input type = button value= ClickMe onclick= details() > </form>

68 Function task Save the file as functionexample.html Find out the value of name Find out which gender has been selected Write both to the page so they are displayed on screen

69 Function example Make your function details bring up an alert box when ClickMe is clicked. {alert( Lorem ipsum ); } Substitute suitable text for Lorem ipsum

70 Function example Now have your alert box return a value from your input box along with the text.

71 Function example { alert("welcome - " + fullname); } <form name="detailsform"> Enter full name <input type ="text" id="fullname"/><br> <input type="button" onclick="details(fullname.value)" value="clickme"/>

72 Functions Separate piece of code which can be called and executed whenever desired. Can be written anywhere in the web-page or in a different page Look like this: <script> Function hello() { alert( Hello! ) } </script>

73 Functions... Brackets beside the name allow a parameter to be passed to the function when running. Also allow a value to be passed back to the main code once the function has run. Prompt box takes an input from user: X=prompt( message, )

74 Function activity <head><script type= text/vbscript > Function topping() { Topp=prompt( Enter a topping, ) Alert(topp + + food) } </script></head>

75 Function activity... <body> <script type= text/vbscript > Food= pizza Topping(food) </script> </body>

76 Function activity Create the pizza script. Adapt it to allow the user to enter their favourite food If the favourite food is pizza then call the topping function

77 Properties Characteristics of objects in code eg: Type Name can have more than one element with same name id must be unique Value Width height

78 Handling events Javascript is an event-driven language An event is an action which triggers a reaction from the code. An event handler is a routine that picks up an action that affects the object Eg onmouseover, onclick Many Javascript events will be triggered in this way. They work like this...

79 Onfocus event <form> Other examples (event handling) <input type = text onfocus= alert( An onfocus event ) </form> Onmouseover event <img src= image1.gif OnMouseOver=alert( An onmouseover event ) Onload event <body onload=alert( loaded )> Text of the alert must not contain spaces. Can do more by calling a function from the onload. <body onload= functionname () >

80 Event driven example... <html> <head> <title>using Javascript</title> <script type= text/javascript > </head> <body> </body> </html>

81 Event driven example... After <script type= text/javascript > add Function showalert() { Alert( Hello world! ); } </script>

82 Event driven example... In the body add... <form method= post action = >//the method attribute is post <p><button type= button name = callscript onclick= showalert(); >/* This is a button tag with the name attribute callscript, it has an onclick event with a value of showalerttext for the button eg.*/ show the alert </button></p> </form> Save the page, open and explore.

83 Event handling An event that triggers a piece of code Some examples and further explanation are here: s.html#h

84 M2 Client vs server is not needed Compare examples of object-orientated and eventdriven Explain how Javascript improves functionality: Drop-down menus Mouse-followers Image galleries Validation Browser detection Create cookies Read/write/modify HTML elements hiding or showing elements moving elements changing colors or fonts

85 D1 Understanding client-side scripting Sheryl Canter, April ,00.asp

Introduction to JavaScript

Introduction to JavaScript 127 Lesson 14 Introduction to JavaScript Aim Objectives : To provide an introduction about JavaScript : To give an idea about, What is JavaScript? How to create a simple JavaScript? More about Java Script

More information

The first sample. What is JavaScript?

The first sample. What is JavaScript? Java Script Introduction JavaScript is the most popular scripting language on the internet, and works in all major browsers, such as Internet Explorer, Firefox, Chrome, Opera, and Safari. In this lecture

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

Lesson 6: Introduction to Functions

Lesson 6: Introduction to Functions JavaScript 101 6-1 Lesson 6: Introduction to Functions OBJECTIVES: In this lesson you will learn about Functions Why functions are useful How to declare a function How to use a function Why functions are

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

Place User-Defined Functions in the HEAD Section

Place 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 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

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

Q1. What is JavaScript?

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

JavaScript Introduction

JavaScript Introduction JavaScript Introduction JavaScript is the most popular scripting language on the internet, and works in all major browsers, such as Internet Explorer, Firefox, Chrome, Opera, and Safari. What is JavaScript?

More information

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

Web Development & Design Foundations with HTML5

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

Lecture 14. Introduction to JavaScript. Mr. Mubashir Ali Lecturer (Dept. of Computer Science)

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

Syllabus - July to Sept

Syllabus - July to Sept Class IX Sub: Computer Syllabus - July to Sept What is www: The World Wide Web (www, W3) is an information space where documents and other web resources are identified by URIs, interlinked by hypertext

More information

Mobile Site Development

Mobile 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 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

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

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

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

HTML, CSS, JavaScript

HTML, CSS, JavaScript HTML, CSS, JavaScript Encoding Information: There s more! Bits and bytes encode the information, but that s not all Tags encode format and some structure in word processors Tags encode format and some

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

Session 16. JavaScript Part 1. Reading

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

1. Cascading Style Sheet and JavaScript

1. Cascading Style Sheet and JavaScript 1. Cascading Style Sheet and JavaScript Cascading Style Sheet or CSS allows you to specify styles for visual element of the website. Styles specify the appearance of particular page element on the screen.

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

UNIT 3 SECTION 1 Answer the following questions Q.1: What is an editor? editor editor Q.2: What do you understand by a web browser?

UNIT 3 SECTION 1 Answer the following questions Q.1: What is an editor? editor editor Q.2: What do you understand by a web browser? UNIT 3 SECTION 1 Answer the following questions Q.1: What is an editor? A 1: A text editor is a program that helps you write plain text (without any formatting) and save it to a file. A good example is

More information

(Refer Slide Time: 01:40)

(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 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

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

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

PIC 40A. Midterm 1 Review

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

Controlled 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. 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 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

Manju Muralidharan Priya. CS4PM Web Aesthetics and Development WEEK 12

Manju Muralidharan Priya. CS4PM Web Aesthetics and Development WEEK 12 CS4PM Web Aesthetics and Development WEEK 12 Objective: 1. Understand the basic operations in JavaScript 2. Understand and Prepare a 3 page Website (Homework for Week 15) 3. Finish Quiz 2 Outline: a. Basics

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

Chapter 9 - JavaScript: Control Structures II

Chapter 9 - JavaScript: Control Structures II Chapter 9 - JavaScript: Control Structures II Outline 9.1 Introduction 9.2 Essentials of Counter-Controlled Repetition 9.3 for Repetition Structure 9. Examples Using the for Structure 9.5 switch Multiple-Selection

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

JavaScript is described in detail in many books on the subject, and there is excellent tutorial material at

JavaScript is described in detail in many books on the subject, and there is excellent tutorial material at JavaScript (last updated April 15, 2013: LSS) JavaScript is a scripting language, specifically for use on web pages. It runs within the browser (that is to say, it is a client- side scripting language),

More information

Web Engineering (Lecture 06) JavaScript part 2

Web Engineering (Lecture 06) JavaScript part 2 Web Engineering (Lecture 06) JavaScript part 2 By: Mr. Sadiq Shah Lecturer (CS) Class BS(IT)-6 th semester JavaScript Events HTML events are "things" that happen to HTML elements. javascript lets you execute

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

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

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

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

Netscape Introduction to the JavaScript Language

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

Introduction to DHTML

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

Chapter 10 JavaScript/JScript: Control Structures II 289

Chapter 10 JavaScript/JScript: Control Structures II 289 IW3HTP_10.fm Page 289 Thursday, April 13, 2000 12:32 PM Chapter 10 JavaScript/JScript: Control Structures II 289 10 JavaScript/JScript: Control Structures II 1

More information

JS Tutorial 3: InnerHTML Note: this part is in last week s tutorial as well, but will be included in this week s lab

JS Tutorial 3: InnerHTML Note: this part is in last week s tutorial as well, but will be included in this week s lab JS Tutorial 3: InnerHTML Note: this part is in last week s tutorial as well, but will be included in this week s lab What if we want to change the text of a paragraph or header on a page? You can use:

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

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

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

LECTURE-2. Functions review HTML Forms. Arrays Exceptions Events. CS3101: Scripting Languages: Javascript Ramana Isukapalli

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

JavaScript by Vetri. Creating a Programmable Web Page

JavaScript by Vetri. Creating a Programmable Web Page XP JavaScript by Vetri Creating a Programmable Web Page 1 XP Tutorial Objectives o Understand basic JavaScript syntax o Create an embedded and external script o Work with variables and data o Work with

More information

Exercise 1: Basic HTML and JavaScript

Exercise 1: Basic HTML and JavaScript Exercise 1: Basic HTML and JavaScript Question 1: Table Create HTML markup that produces the table as shown in Figure 1. Figure 1 Question 2: Spacing Spacing can be added using CellSpacing and CellPadding

More information

Then there are methods ; each method describes an action that can be done to (or with) the object.

Then there are methods ; each method describes an action that can be done to (or with) the object. When the browser loads a page, it stores it in an electronic form that programmers can then access through something known as an interface. The interface is a little like a predefined set of questions

More information

PES DEGREE COLLEGE BANGALORE SOUTH CAMPUS 1 K.M. before Electronic City, Bangalore WEB PROGRAMMING Solution Set II

PES DEGREE COLLEGE BANGALORE SOUTH CAMPUS 1 K.M. before Electronic City, Bangalore WEB PROGRAMMING Solution Set II PES DEGREE COLLEGE BANGALORE SOUTH CAMPUS 1 K.M. before Electronic City, Bangalore 560 100 WEB PROGRAMMING Solution Set II Section A 1. This function evaluates a string as javascript statement or expression

More information

Task 1. Set up Coursework/Examination Weights

Task 1. Set up Coursework/Examination Weights Lab02 Page 1 of 6 Lab 02 Student Mark Calculation HTML table button textbox JavaScript comments function parameter and argument variable naming Number().toFixed() Introduction In this lab you will create

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. Computer Science & Engineering LOGO

JAVASCRIPT. Computer Science & Engineering LOGO JAVASCRIPT JavaScript and Client-Side Scripting When HTML was first developed, Web pages were static Static Web pages cannot change after the browser renders them HTML and XHTML could only be used to produce

More information

CSS The web browser uses its own resources, and eases the burden on the server. It has fewer features than server side scripting.

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

EVENT-DRIVEN PROGRAMMING

EVENT-DRIVEN PROGRAMMING LESSON 13 EVENT-DRIVEN PROGRAMMING This lesson shows how to package JavaScript code into self-defined functions. The code in a function is not executed until the function is called upon by name. This is

More information

CISH-6510 Web Application Design and Development. Overview of JavaScript. Overview

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

Just add an HTML comment tag <!-- before the first JavaScript statement, and an end-of comment tag --> after the last JavaScript statement, like this:

Just add an HTML comment tag <!-- before the first JavaScript statement, and an end-of comment tag --> after the last JavaScript statement, like this: JavaScript Basic JavaScript How To and Where To JavaScript Statements and Comments JavaScript Variables JavaScript Operators JavaScript Comparisons JavaScript If Else JavaScript Loops JavaScript Flow Control

More information

Exercise 1 Using Boolean variables, incorporating JavaScript code into your HTML webpage and using the document object

Exercise 1 Using Boolean variables, incorporating JavaScript code into your HTML webpage and using the document object CS1046 Lab 5 Timing: This lab should take you approximately 2 hours. Objectives: By the end of this lab you should be able to: Recognize a Boolean variable and identify the two values it can take Calculate

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

JavaScript Introduction

JavaScript Introduction JavaScript Introduction JavaScript: Writing Into HTML Output document.write("this is a heading"); document.write("this is a paragraph"); JavaScript: Reacting to Events

More information

JavaScript code is inserted between tags, just like normal HTML tags:

JavaScript code is inserted between tags, just like normal HTML tags: Introduction to JavaScript In this lesson we will provide a brief introduction to JavaScript. We won t go into a ton of detail. There are a number of good JavaScript tutorials on the web. What is JavaScript?

More information

CITS1231 Web Technologies. JavaScript

CITS1231 Web Technologies. JavaScript CITS1231 Web Technologies JavaScript Contents Introduction to JavaScript Variables Operators Conditional Statements Program Loops Popup Boxes Functions 2 User Interaction User interaction requires web

More information

Tizen Web UI Technologies (Tizen Ver. 2.3)

Tizen Web UI Technologies (Tizen Ver. 2.3) Tizen Web UI Technologies (Tizen Ver. 2.3) Spring 2015 Soo Dong Kim, Ph.D. Professor, Department of Computer Science Software Engineering Laboratory Soongsil University Office 02-820-0909 Mobile 010-7392-2220

More information

JavaScript: Introduction to Scripting

JavaScript: Introduction to Scripting iw3htp2.book Page 194 Wednesday, July 18, 2001 9:01 AM 7 JavaScript: Introduction to Scripting Objectives To be able to write simple JavaScript programs. To be able to use input and output statements.

More information

Loops/Confirm Tutorial:

Loops/Confirm Tutorial: Loops/Confirm Tutorial: What you ve learned so far: 3 ways to call a function how to write a function how to send values into parameters in a function How to create an array (of pictures, of sentences,

More information

Web Site Development with HTML/JavaScrip

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

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

Namma Kalvi.

Namma Kalvi. Namma Kalvi COMPUTER APPLICATION PUBLIC EXAM - 2019 ANSWER KEY PART - A I Choose the correct answer 10x1=10 1. c. warm booting 6. d. All the above 11. d..css 2. c. Giga 7. d. 2 12. b. F5 3. b. VGA connector

More information

NEW WEBMASTER HTML & CSS FOR BEGINNERS COURSE SYNOPSIS

NEW WEBMASTER HTML & CSS FOR BEGINNERS COURSE SYNOPSIS NEW WEBMASTER HTML & CSS FOR BEGINNERS COURSE SYNOPSIS LESSON 1 GETTING STARTED Before We Get Started; Pre requisites; The Notepad++ Text Editor; Download Chrome, Firefox, Opera, & Safari Browsers; The

More information

JAVASCRIPT LOOPS. Date: 13/05/2012 Page: 1 Total Chars: 4973 Total Words: 967

JAVASCRIPT LOOPS. Date: 13/05/2012 Page: 1 Total Chars: 4973 Total Words: 967 Date: 13/05/2012 Procedure: JavaScript - Loops Source: LINK (http://webcheatsheet.com/javascript/loops.php) Permalink: LINK (http://heelpbook.altervista.org/2012/javascript-loops) Created by: HeelpBook

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

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

Dynamism and Detection

Dynamism and Detection 1 Dynamism and Detection c h a p t e r ch01 Page 1 Wednesday, June 23, 1999 2:52 PM IN THIS CHAPTER Project I: Generating Platform-Specific Content Project II: Printing Copyright Information and Last-Modified

More information

A340 Laboratory Session #5

A340 Laboratory Session #5 A340 Laboratory Session #5 LAB GOALS Creating multiplication table using JavaScript Creating Random numbers using the Math object Using your text editor (Notepad++ / TextWrangler) create a web page similar

More information

COMS W3101: SCRIPTING LANGUAGES: JAVASCRIPT (FALL 2018)

COMS W3101: SCRIPTING LANGUAGES: JAVASCRIPT (FALL 2018) COMS W3101: SCRIPTING LANGUAGES: JAVASCRIPT (FALL 2018) 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

As we design and build out our HTML pages, there are some basics that we may follow for each page, site, and application.

As we design and build out our HTML pages, there are some basics that we may follow for each page, site, and application. Extra notes - Client-side Design and Development Dr Nick Hayward HTML - Basics A brief introduction to some of the basics of HTML. Contents Intro element add some metadata define a base address

More information

Note: Java and JavaScript are two completely different languages in both concept and design!

Note: Java and JavaScript are two completely different languages in both concept and design! Java Script: 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 directly

More information

COMP519 Web Programming Lecture 16: JavaScript (Part 7) Handouts

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

Events: another simple example

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

New Media Production Lecture 7 Javascript

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

Lesson 1: Writing Your First JavaScript

Lesson 1: Writing Your First JavaScript JavaScript 101 1-1 Lesson 1: Writing Your First JavaScript OBJECTIVES: In this lesson you will be taught how to Use the tag Insert JavaScript code in a Web page Hide your JavaScript

More information

Intro to Programming. Unit 7. What is Programming? What is Programming? Intro to Programming

Intro to Programming. Unit 7. What is Programming? What is Programming? Intro to Programming Intro to Programming Unit 7 Intro to Programming 1 What is Programming? 1. Programming Languages 2. Markup vs. Programming 1. Introduction 2. Print Statement 3. Strings 4. Types and Values 5. Math Externals

More information

Midterm Exam. 5. What is the character - (minus) used for in JavaScript? Give as many answers as you can.

Midterm Exam. 5. What is the character - (minus) used for in JavaScript? Give as many answers as you can. First Name Last Name CSCi 90.3 March 23, 2010 Midterm Exam Instructions: For multiple choice questions, circle the letter of the one best choice unless the question explicitly states that it might have

More information

Project 3 Web Security Part 1. Outline

Project 3 Web Security Part 1. Outline Project 3 Web Security Part 1 CS155 Indrajit Indy Khare Outline Quick Overview of the Technologies HTML (and a bit of CSS) Javascript PHP Assignment Assignment Overview Example Attack 1 New to web programming?

More information

Software. Programming Languages. Types of Software. Types of Languages. Types of Programming. Software does something

Software. Programming Languages. Types of Software. Types of Languages. Types of Programming. Software does something Software Software does something LBSC 690: Week 10 Programming, JavaScript Jimmy Lin College of Information Studies University of Maryland Monday, April 9, 2007 Tells the machine how to operate on some

More information

Chapter 1 Getting Started with HTML 5 1. Chapter 2 Introduction to New Elements in HTML 5 21

Chapter 1 Getting Started with HTML 5 1. Chapter 2 Introduction to New Elements in HTML 5 21 Table of Contents Chapter 1 Getting Started with HTML 5 1 Introduction to HTML 5... 2 New API... 2 New Structure... 3 New Markup Elements and Attributes... 3 New Form Elements and Attributes... 4 Geolocation...

More information

Lesson 5: Introduction to Events

Lesson 5: Introduction to Events JavaScript 101 5-1 Lesson 5: Introduction to Events OBJECTIVES: In this lesson you will learn about Event driven programming Events and event handlers The onclick event handler for hyperlinks The onclick

More information

LECTURE-3. Exceptions JS Events. CS3101: Programming Languages: Javascript Ramana Isukapalli

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

HTML. Mohammed Alhessi M.Sc. Geomatics Engineering. Internet GIS Technologies كلية اآلداب - قسم الجغرافيا نظم المعلومات الجغرافية

HTML. Mohammed Alhessi M.Sc. Geomatics Engineering. Internet GIS Technologies كلية اآلداب - قسم الجغرافيا نظم المعلومات الجغرافية HTML Mohammed Alhessi M.Sc. Geomatics Engineering Wednesday, February 18, 2015 Eng. Mohammed Alhessi 1 W3Schools Main Reference: http://www.w3schools.com/ 2 What is HTML? HTML is a markup language for

More information

JAVASCRIPT. JavaScript is the programming language of HTML and the Web. JavaScript Java. JavaScript is interpreted by the browser.

JAVASCRIPT. JavaScript is the programming language of HTML and the Web. JavaScript Java. JavaScript is interpreted by the browser. JAVASCRIPT JavaScript is the programming language of HTML and the Web. JavaScript Java JavaScript is interpreted by the browser JavaScript 1/15 JS WHERE TO

More information

Exam : 9A Title : Adobe GoLive CS2 ACE Exam. Version : DEMO

Exam : 9A Title : Adobe GoLive CS2 ACE Exam. Version : DEMO Exam : 9A0-046 Title : Adobe GoLive CS2 ACE Exam Version : DEMO 1. Which scripting language is the default for use with ASP, and does NOT require a language specification at the beginning of a Web page's

More information

Acknowledgments. Who Should Read This Book?...xxiv How to Read This Book...xxiv What s in This Book?...xxv Have Fun!...xxvi

Acknowledgments. Who Should Read This Book?...xxiv How to Read This Book...xxiv What s in This Book?...xxv Have Fun!...xxvi Contents IN DeTAIl Acknowledgments xxi Introduction xxiii Who Should Read This Book?....xxiv How to Read This Book....xxiv What s in This Book?...xxv Have Fun!...xxvi Part I: Fundamentals 1 What Is JavaScript?

More information

Sections and Articles

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