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

Size: px
Start display at page:

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

Transcription

1 PES DEGREE COLLEGE BANGALORE SOUTH CAMPUS 1 K.M. before Electronic City, Bangalore WEB PROGRAMMING Solution Set II Section A 1. This function evaluates a string as javascript statement or expression and either executes it or returns the resulting value. A simple example assigns 25 to a variable. a=eval( ); 2. The math object allows to perform mathematical tasks. Math.abs() - smath.abs(x) returns the absolute (positive) value of x: Math.ceil(x) - returns the value of x rounded up to its nearest integer: Math.floor() - Math.floor(x) returns the value of x rounded down to its nearest integer: 3. The toexponential() Method - toexponential() returns a string, with a number rounded and written using exponential notation. Ex: var x = 9.656; x.toexponential(2); // returns 9.66e+0 x.toexponential(4); // returns e+0 The tofixed() Method - tofixed() returns a string, with the number written with a specified number of decimals: Ex : var x = 9.656; x.tofixed(0); // returns 10 x.tofixed(2); // returns 9.66 The tostring() Method - tostring() returns a number as a string. All number methods can be used on any type of numbers (literals, variables, or expressions): Ex: var x = 123; x.tostring(); // returns 123 from variable x 4. JavaScript can be implemented using JavaScript statements that are placed within the<script>... HTML tags in a web page. <script...> JavaScript code Attributes in script tag Type Src Language 5. The difference between span and div is that a span element is in-line and usually used for a small chunk of HTML inside a line (such as inside a paragraph) whereas a div (division) element is block-line (which is basically equivalent to having a line-break before and after it) and used to group larger chunks of code. Section B 1. There are 4 ways to include javascript code in html. They are: Script in <head>... section. Scripts can be executed when they called, or when an event is triggered, are placed in functions. Ex: <html><head><script...> function message()

2 alert( this is alert box ); <input type= button value= click here onclick= message() /> Script in... section. <script type= text/javascript > document.write( this is javascript ); Script in... and <head>... sections. We can place an unlimited number of scripts in the document, both in head and body section. Ex: <html><head><script...> function message() alert( this is alert box ); document.write( this is javascript ); <input type= button value= click here onclick= message() /> Script in an external file and then include in <head>... section. We can keep javascript scripts in separate files and use the SRC attribute of the SCRIPT tag to include the javascript program in an HTML file. The src attribute can be used as <script type= text/javascript src= javascript.js > EX: <html><head> <script type= text/javascript src= javascript.js > <input type= button value= click here onclick= message() /> " javascript.js function message() alert( this is alert box ); 2. There are 4 ways to create an instance of Date object. Var newdate= new Date(); This creaes a new instance of the object that contains the current date and time at the command was executed. Var somedate = new Date(milliseconds) milliseconds When one numeric argument is passed, it is taken as the internal numeric representation of the date in milliseconds, as returned by the gettime() method. For example, passing the argument

3 5000 creates a date that represents five seconds past midnight on 1/1/70. new Date(datestring) - datestring When one string argument is passed, it is a string representation of a date. Ex: var date= new Date( Tue Feb 26 12:29:22 EST 2002 ) new Date(year,month,date[,hour,minute,second,millisecond ]) Date Methods Date() - Returns today's date and time getdate() - Returns the day of the month for the specified date according to local time. getday() - Returns the day of the week for the specified date according to local time. getfullyear() - Returns the year of the specified date according to local time. gethours() - Returns the hour in the specified date according to local time. getmilliseconds() - Returns the milliseconds in the specified date according to local time. getminutes() - Returns the minutes in the specified date according to local time. getmonth() - Returns the month in the specified date according to local time. getseconds() - Returns the seconds in the specified date according to local time. gettime() - Returns the numeric value of the specified date as the number of milliseconds since January 1, 1970, 00:00:00 UTC. 3. onclick Event Type This is the most frequently used event type which occurs when a user clicks the left button of his mouse. You can put your validation, warning etc., against this event type. <html> <head> <!-- function sayhello() alert("hello World") //--> <p>click the following button and see result</p> <form> <input type="button" onclick="sayhello()" value="say Hello" /> </form> </html> onsubmit Event type onsubmit is an event that occurs when you try to submit a form. You can put your form validation against this event type. The following example shows how to use onsubmit. Here we are calling a validate() function before submitting a form data to the webserver. If validate() function returns true, the form will be submitted, otherwise it will not submit the data. <head> <!-- function validation() all validation goes here... return either true or false //-->

4 <form method="post" onsubmit="return validate()">... <input type="submit" value="submit" /> </form> 4. There are 3 JavaScript methods that can be used to convert variables to numbers: The Number() method The parseint() method The parsefloat() method These methods are not number methods, but global JavaScript methods Global Methods JavaScript global methods can be used on all JavaScript data types. The Number() Method Number() can be used to convert JavaScript variables to numbers: x = true; Number(x); // returns 1 x = false; Number(x); // returns 0 x = "10" Number(x); // returns 10 x = "10 20" Number(x); // returns NaN The parseint() Method parseint() parses a string and returns a whole number. Spaces are allowed. Only the first number is returned: parseint("10"); // returns 10 parseint("10.33"); // returns 10 parseint(" "); // returns 10 parseint("10 years"); // returns 10 parseint("years 10"); // returns NaN The parsefloat() Method parsefloat() parses a string and returns a number. Spaces are allowed. Only the first number is returned: parsefloat("10"); // returns 10 parsefloat("10.33"); // returns parsefloat(" "); // returns 10 parsefloat("10 years"); // returns 10 parsefloat("years 10"); // returns NaN 5. Forms and arrays are defined in DOM 0. DOM 0 uses the forms and elements array of the Document object which is referenced by the document property of the window object. document.forms[number].elements[number] The next approach of DOM addressing is to use element names. Var doc = document.firstform.elementname We can get the value of any element by using: var_name = document.firstform.elementname.value ex: firstname=document.form1.name.value; in the output the variable firstname is assigned with a value. document.form1.name.value document is the root element that represents the html document.

5 form1 is the name of the form. name is the attribute name of the input text. value is the property, that returns the value of the input text. Section C 1. A function is a group of reusable code which can be called anywhere in your program. The most common way to define a function in JavaScript is by using the function keyword, followed by a unique function name, a list of parameters (that might be empty), and a statement block surrounded by curly braces. Syntax function functionname(parameter-list) statements Calling a Function function sayhello() document.write ("Hello there!"); <p>click the following button to call the function</p> <form> <input type="button" onclick="sayhello()" value="say Hello"> </form> In the example above, the function sayhello() is defined in head section and this function is called from body section of program. When the button is clicked, the function is called andthe statements inside the function are executed. The output after the button clicked is "Hello there!" 2. <html> <head> <script type = "text/javascript"> var num = window.prompt("enter the number:",""); var n = parseint(num); result = sumofnaturalno(n); window.alert("the sum of " + n + " "+ "natural number is" +" = " + result); function sumofnaturalno(n) var i; var sum = 0; for(i = 1;i <= n; i++) sum = sum + i; return (sum); function getconfirm()

6 var retval = confirm("do you want to continue?"); if( retval == true ) document.write ("User wants to continue!"); return true; else document.write ("User does not want to continue!"); return false; <p>click the following button to see the result: </p> <form> <input type="button" value="click Me" onclick="getconfirm();" /> </form> </html> 3. String object methods with examples. CharAt() - Returns the character at the specified index. CharCodeAt() - Returns a number indicating the Unicode value of the character at the given index. Concat() - Combines the text of two strings and returns a new string. IndexOf() - Returns the index within the calling String object of the first occurrence of the specified value, or -1 if not found. LastIndexOf() - Returns the index within the calling String object of the last occurrence of the specified value, or -1 if not found. Slice() - Extracts a section of a string and returns a new string. split() - Splits a String object into an array of strings by separating the string into substrings. Substr() - Returns the characters in a string beginning at the specified location through the specified number of characters.substring() - Returns the characters in a string between two indexes into the string. tolowercase() - Returns the calling string value converted to lower case. touppercase() - Returns the calling string value converted to uppercase. <html> <head> <title>javascript String constructor Method</title> var str = new String( "This is string" ); document.write("<br /> str.length is:" + str.length); document.write("<br />str.charat(9) is:" + str.charat(9)); document.write("<br />str.charcodeat(1) is:" + str.charcodeat(1)); var str2 = new String( "2nd string concatenated with 1st string " ); var str3 = str.concat( str2 ); document.write(" <br />Concatenated String :" + str3); var index = str2.indexof( "string" ); document.write("<br />indexof found String :" + index ); var index = str2.lastindexof( "string" );

7 document.write("<br />lastindexof found String :" + index ); var sliced = str.slice(3,-2); document.write("<br />"+ sliced); var splitted = str2.split("t", 4); document.write( "<br />" + splitted ); document.write("<br />(1,2): " + str.substr(1,2)); document.write("<br />(0,10): " + str.substring(0, 10)); document.write("<br />" +str.touppercase( )); document.write("<br />" +str.tolowercase( )); </html> 4. Document: Each HTML document loaded nto browser window becomes a Document object. They have the properties like cookies, documentmode, domain, lastmodified, readystae, title, URL. Location: Location object contains info about the current URL. Accessed through the window.location property. They have the properties like host, hostname, href, port, protocol, pathname and search. History: Contains the URLs visited by the user. Window.history property Screen: Contains information about the visitors screen. The properties of screen are height, width, colordepth, availwidth and availheight. Navigator: Contains information about the browser. The properties of navigation object are appcodename, appname, appversion, cookieenabled, platform. Frames: An array of references to the frames of the document. Image : document.images[].property. Link: document.links[].property.

Javascript Methods. concat Method (Array) concat Method (String) charat Method (String)

Javascript Methods. concat Method (Array) concat Method (String) charat Method (String) charat Method (String) The charat method returns a character value equal to the character at the specified index. The first character in a string is at index 0, the second is at index 1, and so forth.

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

What Is JavaScript? A scripting language based on an object-orientated programming philosophy.

What Is JavaScript? A scripting language based on an object-orientated programming philosophy. What Is JavaScript? A scripting language based on an object-orientated programming philosophy. Each object has certain attributes. Some are like adjectives: properties. For example, an object might have

More information

Such JavaScript Very Wow

Such JavaScript Very Wow Such JavaScript Very Wow Lecture 9 CGS 3066 Fall 2016 October 20, 2016 JavaScript Numbers JavaScript numbers can be written with, or without decimals. Extra large or extra small numbers can be written

More information

CITS1231 Web Technologies. JavaScript Math, String, Array, Number, Debugging

CITS1231 Web Technologies. JavaScript Math, String, Array, Number, Debugging CITS1231 Web Technologies JavaScript Math, String, Array, Number, Debugging Last Lecture Introduction to JavaScript Variables Operators Conditional Statements Program Loops Popup Boxes Functions 3 This

More information

PIC 40A. Lecture 10: JS: Wrapper objects, Input and Output, Control structures, random numbers. Copyright 2011 Jukka Virtanen UCLA 1 04/24/17

PIC 40A. Lecture 10: JS: Wrapper objects, Input and Output, Control structures, random numbers. Copyright 2011 Jukka Virtanen UCLA 1 04/24/17 PIC 40A Lecture 10: JS: Wrapper objects, Input and Output, Control structures, random numbers 04/24/17 Copyright 2011 Jukka Virtanen UCLA 1 Objects in JS In C++ we have classes, in JS we have OBJECTS.

More information

UNIT-4 JAVASCRIPT. Prequisite HTML/XHTML. Origins

UNIT-4 JAVASCRIPT. Prequisite HTML/XHTML. Origins UNIT-4 JAVASCRIPT Overview of JavaScript JavaScript is a sequence of statements to be executed by the browser. It is most popular scripting language on the internet, and works in all major browsers, such

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

a Why JavaScript? jonkv interactivity on the web CGI JavaScript Java Applets Netscape LiveScript JavaScript 1: Example

a Why JavaScript? jonkv interactivity on the web CGI JavaScript Java Applets Netscape LiveScript JavaScript 1: Example Why JavaScript? 2 JavaScript JavaScript the language Web page manipulation with JavaScript and the DOM 1994 1995: Wanted interactivity on the web Server side interactivity: CGI Common Gateway Interface

More information

Javascript Hierarchy Objects Object Properties Methods Event Handlers. onload onunload onblur onfocus

Javascript Hierarchy Objects Object Properties Methods Event Handlers. onload onunload onblur onfocus Javascript Hierarchy Objects Object Properties Methods Event Handlers Window Frame Location History defaultstatus frames opener parent scroll self status top window defaultstatus frames opener parent scroll

More information

INTRODUCTION TO WEB DEVELOPMENT AND HTML. Lecture 15: JavaScript loops, Objects, Events - Spring 2011

INTRODUCTION TO WEB DEVELOPMENT AND HTML. Lecture 15: JavaScript loops, Objects, Events - Spring 2011 INTRODUCTION TO WEB DEVELOPMENT AND HTML Lecture 15: JavaScript loops, Objects, Events - Spring 2011 Outline Selection Statements (if, if-else, switch) Loops (for, while, do..while) Built-in Objects: Strings

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

More on new. Today s Goals. CSCI 2910 Client/Server-Side Programming. Creating/Defining Objects. Creating/Defining Objects (continued)

More on new. Today s Goals. CSCI 2910 Client/Server-Side Programming. Creating/Defining Objects. Creating/Defining Objects (continued) CSCI 2910 Client/Server-Side Programming Topic: Advanced JavaScript Topics Today s Goals Today s lecture will cover: More on new and objects Built in objects Image, String, Date, Boolean, and Number The

More information

About the Tutorial. Audience. Prerequisites. Copyright and Disclaimer

About the Tutorial. Audience. Prerequisites. Copyright and Disclaimer About the Tutorial JavaScript is a lightweight, interpreted programming language. It is designed for creating network-centric applications. It is complimentary to and integrated with Java. JavaScript is

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

Chapter 4 Basics of JavaScript

Chapter 4 Basics of JavaScript Chapter 4 Basics of JavaScript JavaScript/EcmaScript References The official EcmaScript, third edition, specification http://www.ecma-international.org/publications/files/ecma-st/ecma-262.pdf A working

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

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

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

COMS 469: Interactive Media II

COMS 469: Interactive Media II COMS 469: Interactive Media II Agenda Review Ch. 7: HTML Forms Ch. 9: String Manipulation Review Object Oriented Programming JavaScript Native Objects Browser Objects Review OOP Terminology Object Properties

More information

CS1520 Recitation Week 2

CS1520 Recitation Week 2 CS1520 Recitation Week 2 Javascript http://cs.pitt.edu/~jlee/teaching/cs1520 Jeongmin Lee, (jlee@cs.pitt.edu) Today - Review of Syntax - Embed code - Syntax - Declare variable - Numeric, String, Datetime

More information

Like most objects, String objects need to be created before they can be used. To create a String object, we can write

Like most objects, String objects need to be created before they can be used. To create a String object, we can write JavaScript Native Objects Broswer Objects JavaScript Native Objects So far we have just been looking at what objects are, how to create them, and how to use them. Now, let's take a look at some of the

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

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

Information Design. Professor Danne Woo! infodesign.dannewoo.com! ARTS 269 Fall 2018 Friday 10:00PM 1:50PM I-Building 212

Information Design. Professor Danne Woo! infodesign.dannewoo.com! ARTS 269 Fall 2018 Friday 10:00PM 1:50PM I-Building 212 Information Design Professor Danne Woo! infodesign.dannewoo.com! ARTS 269 Fall 2018 Friday 10:00PM 1:50PM I-Building 212 Interactive Data Viz Week 8: Data, the Web and Datavisual! Week 9: JavaScript and

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

JAVASCRIPT BASICS. JavaScript String Functions. Here is the basic condition you have to follow. If you start a string with

JAVASCRIPT BASICS. JavaScript String Functions. Here is the basic condition you have to follow. If you start a string with JavaScript String Functions Description String constants can be specified by enclosing characters or strings within double quotes, e.g. "WikiTechy is the best site to learn JavaScript". A string constant

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

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

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

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

CECS 189D EXAMINATION #1

CECS 189D EXAMINATION #1 CECS 189D EXAMINATION #1 SPRING 10 70 points MULTIPLE CHOICE 2 points for each correct answer Identify the choice that best answers the question on a Scantron 882 with a pencil #2. When you're on the campus

More information

F.Y. B.Sc.(IT) : Sem. II. Web Programming

F.Y. B.Sc.(IT) : Sem. II. Web Programming F.Y. B.Sc.(IT) : Sem. II Web Programming Time : 2½ Hrs.] Prelim Question Paper Solution [Marks : 75 Q.1 Attempt the following (any THREE) [15] Q.1(a) What is Internet? Explain its applications? [5] (A)

More information

Lecture 17. History, Navigator, Screen and Form Objects. Mr. Mubashir Ali Lecturer (Dept. of Computer Science)

Lecture 17. History, Navigator, Screen and Form Objects. Mr. Mubashir Ali Lecturer (Dept. of Computer Science) Lecture 17 History, Navigator, Screen and Form Objects Mr. Mubashir Ali Lecturer (Dept. of Computer Science) dr.mubashirali1@gmail.com 1 Summary of the previous lecture Controlling the background dynamically

More information

Chapter 16. JavaScript 3: Functions Table of Contents

Chapter 16. JavaScript 3: Functions Table of Contents Chapter 16. JavaScript 3: Functions Table of Contents Objectives... 2 14.1 Introduction... 2 14.1.1 Introduction to JavaScript Functions... 2 14.1.2 Uses of Functions... 2 14.2 Using Functions... 2 14.2.1

More information

Full file at https://fratstock.eu Tutorial 2: Working with Operators and Expressions

Full file at https://fratstock.eu Tutorial 2: Working with Operators and Expressions Tutorial 2: Working with Operators and Expressions TRUE/FALSE 1. You can add a dynamic effect to a Web site using ontime processing. ANS: F PTS: 1 REF: JVS 54 2. You can not insert values into a Web form

More information

write vs. writeln Prompting as Page Loads Today s Goals CSCI 2910 Client/Server-Side Programming Intermediate File vs. HTML Output

write vs. writeln Prompting as Page Loads Today s Goals CSCI 2910 Client/Server-Side Programming Intermediate File vs. HTML Output CSCI 2910 Client/Server-Side Programming Topic: JavaScript Part 2 Today s Goals Today s lecture will cover: More objects, properties, and methods of the DOM The Math object Introduction to form validation

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

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

Lecture 3: The Basics of JavaScript. Background. Needs for Programming Capability. Origin of JavaScript. Using Client-side JavaScript

Lecture 3: The Basics of JavaScript. Background. Needs for Programming Capability. Origin of JavaScript. Using Client-side JavaScript Lecture 3: The Basics of JavaScript Wendy Liu CSC309F Fall 2007 Background Origin and facts 1 2 Needs for Programming Capability XHTML and CSS allows the browser to passively display static content How

More 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

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

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

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

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

ID1354 Internet Applications

ID1354 Internet Applications ID1354 Internet Applications JavaScript Leif Lindbäck, Nima Dokoohaki leifl@kth.se, nimad@kth.se SCS/ICT/KTH Overview of JavaScript Originally developed by Netscape, as LiveScript Became a joint venture

More information

4.1 Overview of JavaScript

4.1 Overview of JavaScript 4.1 Overview of JavaScript - Originally developed by Netscape by Brendan Eich, as LiveScript - Became a joint venture of Netscape and Sun in 1995, renamed JavaScript - Now standardized by the European

More information

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

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

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

IDM 231. Functions, Objects and Methods

IDM 231. Functions, Objects and Methods IDM 231 Functions, Objects and Methods IDM 231: Scripting for IDM I 1 Browsers require very detailed instructions about what we want them to do. Therefore, complex scripts can run to hundreds (even thousands)

More information

Contents. Osp::Base::Object Osp::Base::String Osp::Base::Buffer Osp::Base::DateTime

Contents. Osp::Base::Object Osp::Base::String Osp::Base::Buffer Osp::Base::DateTime Osp::Base Contents Osp::Base::Object Osp::Base::String Osp::Base::Buffer Osp::Base::DateTime Intorduction The Base namespace contains classes and interfaces around which the entire bada is built. All bada

More information

Best Practices Chapter 5

Best Practices Chapter 5 Best Practices Chapter 5 Chapter 5 CHRIS HOY 12/11/2015 COMW-283 Chapter 5 The DOM and BOM The BOM stand for the Browser Object Model, it s also the client-side of the web hierarchy. It is made up of a

More information

introjs.notebook March 02, 2014

introjs.notebook March 02, 2014 1 document.write() uses the write method to write on the document. It writes the literal Hello World! which is enclosed in quotes since it is a literal and then enclosed in the () of the write method.

More information

Basics of JavaScript. Last Week. Needs for Programming Capability. Browser as Development Platform. Using Client-side JavaScript. Origin of JavaScript

Basics of JavaScript. Last Week. Needs for Programming Capability. Browser as Development Platform. Using Client-side JavaScript. Origin of JavaScript Basics of JavaScript History of the Web XHTML CSS Last Week Nan Niu (nn@cs.toronto.edu) CSC309 -- Fall 2008 2 Needs for Programming Capability XHTML and CSS allows the browser to passively display static

More information

JAVASCRIPT BASICS. Type-Conversion in JavaScript. Type conversion or typecasting is one of the very important concept in

JAVASCRIPT BASICS. Type-Conversion in JavaScript. Type conversion or typecasting is one of the very important concept in Type-Conversion in JavaScript Description Type conversion or typecasting is one of the very important concept in JavaScript. It refers to changing an entity or variable from one datatype to another. There

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

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

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

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

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

Assoc. Prof. Marenglen Biba. (C) 2010 Pearson Education, Inc. All rights reserved.

Assoc. Prof. Marenglen Biba. (C) 2010 Pearson Education, Inc. All rights reserved. Assoc. Prof. Marenglen Biba (C) 2010 Pearson Education, Inc. All This chapter discusses class String, from the java.lang package. These classes provide the foundation for string and character manipulation

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: Learn about the Document Object Model and the Document Object Model hierarchy Create and use the properties, methods and event

More information

Indian Institute of Technology Kharagpur. Javascript Part III. Prof. Indranil Sen Gupta Dept. of Computer Science & Engg. I.I.T.

Indian Institute of Technology Kharagpur. Javascript Part III. Prof. Indranil Sen Gupta Dept. of Computer Science & Engg. I.I.T. Indian Institute of Technology Kharagpur Javascript Part III Prof. Indranil Sen Gupta Dept. of Computer Science & Engg. I.I.T. Kharagpur, INDIA Lecture 27: Javascript Part III On completion, the student

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

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

Assoc. Prof. Marenglen Biba. (C) 2010 Pearson Education, Inc. All rights reserved.

Assoc. Prof. Marenglen Biba. (C) 2010 Pearson Education, Inc. All rights reserved. Assoc. Prof. Marenglen Biba (C) 2010 Pearson Education, Inc. All Advanced Java This chapter discusses class String, class StringBuilder and class Character from the java.lang package. These classes provide

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

Document Object Model (DOM)

Document Object Model (DOM) Document Object Model (DOM) HTML DOM The Document Object Model is a platform- and language-neutral interface that will allow programs and scripts to dynamically access and update the content, structure

More information

Try the following example using the Try it option available at the top right corner of the below sample code box

Try the following example using the Try it option available at the top right corner of the below sample code box About the Tutorial CoffeeScript is a lightweight language which transcompiles into JavaScript. It provides better syntax avoiding the quirky parts of JavaScript, still retaining the flexibility and beauty

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

Tema 5 JavaScript JavaScriptand and

Tema 5 JavaScript JavaScriptand and escuela técnica superior de ingeniería informática Versión original: Amador Durán, David Benavides y Pablo Fernandez (noviembre 2006 Manuel Resinas (noviembre 2007); Reestructuración de contenido. Última

More information

COMP519 Web Programming Lecture 14: JavaScript (Part 5) Handouts

COMP519 Web Programming Lecture 14: JavaScript (Part 5) Handouts COMP519 Web Programming Lecture 14: JavaScript (Part 5) Handouts Ullrich Hustadt Department of Computer Science School of Electrical Engineering, Electronics, and Computer Science University of Liverpool

More information

INTRODUCTION TO WEB DEVELOPMENT AND HTML. Lecture 13: Intro to JavaScript - Spring 2011

INTRODUCTION TO WEB DEVELOPMENT AND HTML. Lecture 13: Intro to JavaScript - Spring 2011 INTRODUCTION TO WEB DEVELOPMENT AND HTML Lecture 13: Intro to JavaScript - Spring 2011 Outline Intro to JavaScript What is JavaScript? JavaScript!= Java Intro to JavaScript JavaScript is a lightweight

More information

JavaScript!= Java. Intro to JavaScript. What is JavaScript? Intro to JavaScript 4/17/2013 INTRODUCTION TO WEB DEVELOPMENT AND HTML

JavaScript!= Java. Intro to JavaScript. What is JavaScript? Intro to JavaScript 4/17/2013 INTRODUCTION TO WEB DEVELOPMENT AND HTML INTRODUCTION TO WEB DEVELOPMENT AND HTML Intro to JavaScript Lecture 13: Intro to JavaScript - Spring 2013 What is JavaScript? JavaScript!= Java Intro to JavaScript JavaScript is a lightweight programming

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

Chapter 12. JavaScript 1: Basic Scripting Table of Contents

Chapter 12. JavaScript 1: Basic Scripting Table of Contents Chapter 12. JavaScript 1: Basic Scripting Table of Contents Objectives... 2 11.1 Introduction... 2 11.1.1 Differences between JavaScript and Java... 2 11.2 JavaScript within HTML... 3 11.2.1 Arguments...

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

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

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

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

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

Lab 3 - Pizza. Purpose. Assignment

Lab 3 - Pizza. Purpose. Assignment Lab 3 - Pizza Purpose To assess your ability to apply the knowledge and skills developed in weeks 1 through 9. Emphasis will be placed on the following learning outcomes: 1. Create syntactically correct

More information

Lab 1 Concert Ticket Calculator

Lab 1 Concert Ticket Calculator Lab 1 Concert Ticket Calculator Purpose To assess your ability to apply the knowledge and skills developed in weeks 1 through 3. Emphasis will be placed on the following learning outcomes: 1. Create and

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

Manipulating Data in Strings and Arrays

Manipulating Data in Strings and Arrays Manipulating Data in Strings and Arrays In this chapter, you will: Manipulate strings Work with regular expressions Manipulate arrays Convert between strings and arrays Manipulating Data in Strings and

More information

CSc 337 LECTURE 5: GRID LAYOUT AND JAVASCRIPT

CSc 337 LECTURE 5: GRID LAYOUT AND JAVASCRIPT CSc 337 LECTURE 5: GRID LAYOUT AND JAVASCRIPT Layouts Flexbox - designed for one-dimensional layouts Grid - designed for two-dimensional layouts Grid Layout Use if you want rows and columns Works similarly

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

JavaScript: More Syntax and Using Events

JavaScript: More Syntax and Using Events JavaScript: Me Syntax and Using Events CISC 282 October 4, 2017 null and undefined null is synonymous with nothing i.e., no value, nothing there undefined in synonymous with confusion i.e., what's this?

More information

The Irving K. Barber School of Arts and Sciences COSC 111 Final Exam Winter Term II Instructor: Dr. Bowen Hui. Tuesday, April 19, 2016

The Irving K. Barber School of Arts and Sciences COSC 111 Final Exam Winter Term II Instructor: Dr. Bowen Hui. Tuesday, April 19, 2016 First Name (Print): Last Name (Print): Student Number: The Irving K. Barber School of Arts and Sciences COSC 111 Final Exam Winter Term II 2016 Instructor: Dr. Bowen Hui Tuesday, April 19, 2016 Time: 6:00pm

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

Produced by. App Development & Modeling. BSc in Applied Computing. Eamonn de Leastar

Produced by. App Development & Modeling. BSc in Applied Computing. Eamonn de Leastar App Development & Modeling BSc in Applied Computing Produced by Eamonn de Leastar (edeleastar@wit.ie) Department of Computing, Maths & Physics Waterford Institute of Technology http://www.wit.ie http://elearning.wit.ie

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

Programming the Web VALIDATING FORM INPUT

Programming the Web VALIDATING FORM INPUT VALIDATING FORM INPUT One of the common uses of JavaScript is to check the values provided in forms by users to determine whether the values are sensible. When a user fills in a form input element incorrectly

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 2 Professional Program: Data Administration and Management JAVASCRIPT AND JQUERY: AN INTRODUCTION (WEB PROGRAMMING, X452.1) AGENDA

More information

Lesson 7: If Statement and Comparison Operators

Lesson 7: If Statement and Comparison Operators JavaScript 101 7-1 Lesson 7: If Statement and Comparison Operators OBJECTIVES: In this lesson you will learn about Branching or conditional satements How to use the comparison operators: ==,!=, < ,

More information

JavaScript CSCI 201 Principles of Software Development

JavaScript CSCI 201 Principles of Software Development JavaScript CSCI 201 Principles of Software Development Jeffrey Miller, Ph.D. jeffrey.miller@usc.edu Outline JavaScript Program USC CSCI 201L JavaScript JavaScript is a front-end interpreted language that

More information