Full file at Tutorial 2: Working with Operators and Expressions

Size: px
Start display at page:

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

Transcription

1 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 You can not insert values into a Web form s fields. ANS: F PTS: 1 REF: JVS An event is an action that occurs within a Web browser or Web document. ANS: T PTS: 1 REF: JVS In the code <body onload = "myfunction()"...>, myfunction() is executed when the page loads. ANS: T PTS: 1 REF: JVS Across the different web browsers and their versions, there is support for the same set of events. ANS: F PTS: 1 REF: JVS The time object is used in JavaScript to work with dates. ANS: F PTS: 1 REF: JVS You use the thisdate() function to get the current date and time. ANS: F PTS: 1 REF: JVS The getdate() method returns the specific month for a particular date. ANS: F PTS: 1 REF: JVS To get a two digit year, you use the getyear() method. ANS: T PTS: 1 REF: JVS JavaScript only allows the minutes and seconds to be retrieved from a date. ANS: F PTS: 1 REF: JVS JavaScript does not support daylight savings time. ANS: T PTS: 1 REF: JVS When writing your own function, you begin by using the word "method". ANS: F PTS: 1 REF: JVS 63

2 13. Binary operators work on only one operand. ANS: F PTS: 1 REF: JVS You use the ++ operator to increment a variable in JavaScript. ANS: T PTS: 1 REF: JVS To avoid misunderstanding the actions of a decrement operator, read the action of the operator from right to left. ANS: F PTS: 1 REF: JVS If you insert a space between the two symbols of the assignment operator, JavaScript will report a syntax error. ANS: T PTS: 1 REF: JVS JavaScript measures time in terms of days. ANS: F PTS: 1 REF: JVS To use the round method, you type "math.round()". ANS: F PTS: 1 REF: JVS The Math.random() method returns a value between 0 and 1. ANS: T PTS: 1 REF: JVS The value.tofixed(n) method can be used to control the number of digits displayed by the browser. ANS: T PTS: 1 REF: JVS 80 MODIFIED TRUE/FALSE 1. One way of inserting an event handler is to add it as an attribute of the element in the Web document. ANS: T PTS: 1 REF: JVS The onclick event handler handles when the mouse button has been pressed. ANS: F, onmousedown PTS: 1 REF: JVS Another way to run a JavaScript command in response to an event is to treat it as a hypertext form. ANS: F, link

3 PTS: 1 REF: JVS To create a date object, you use new Time(). ANS: F, new Date() PTS: 1 REF: JVS The time methods can be used to retrieve information from a date object. ANS: F, date PTS: 1 REF: JVS The method to get the current hour from a date object is DateObject.getTimeHour(). ANS: F DateObject.getHours() PTS: 1 REF: JVS The gettime() method retrieves the time value as expressed in milliseconds. ANS: T PTS: 1 REF: JVS The operators shown in the figure above are binary operators. ANS: F, unary PTS: 1 REF: JVS The -- operator in the figure above is used to decrement variables. ANS: T PTS: 1 REF: JVS To make a function available to other pages, you should place the function in an external file.

4 ANS: T PTS: 1 REF: JVS The figure above shows an example of a JavaScript object. ANS: F, function PTS: 1 REF: JVS The portion of JavaScript code pointed at in the figure above calculates the number of seconds in a day. ANS: F, milliseconds PTS: 1 REF: JVS The && is a(n) comparison operator. ANS: F, logical PTS: 1 REF: JVS To cancel a time-delayed command called timeone, you would use timeone.cleartimeout(). ANS: F, cleartimeout(timeone) PTS: 1 REF: JVS In the following JavaScript code: settimeout("addthree()",50); settimeout("showdate()",50); the functions execute almost simultaneously.

5 ANS: T PTS: 1 REF: JVS 89 MULTIPLE CHOICE 1. In document.contact.name.value, the name of the form must be. a. Contact c. document b. Name d. value ANS: A PTS: 1 REF: JVS A(n) is a statement that tells browsers what code to run in response to the specified event. a. event script c. unary operator b. event handler d. element attribute ANS: B PTS: 1 REF: JVS The event handler runs when the browser has completed unloading the document. a. onload c. onerror b. onremove d. onunload ANS: D PTS: 1 REF: JVS The event handler tests whether or not a user has pressed and released a button on the keyboard. a. onquit c. onkeydown b. onclick d. onkeypress ANS: D PTS: 1 REF: JVS If a user clicks an item on a page, which event(s) may occur? a. ondblclick c. a only b. onclick d. either a or b ANS: D PTS: 1 REF: JVS The event handler runs when a user has entered a text input field. a. onload c. onfocus b. onchange d. onblur ANS: C PTS: 1 REF: JVS To add code that runs when content of an input field has been modified, you use the event handler. a. onload c. onfocus b. onchange d. onblur ANS: B PTS: 1 REF: JVS To have the function verify() execute when a person leaves the Name input field, you must use the event handler. a. onload c. onfocus b. onchange d. onblur ANS: D PTS: 1 REF: JVS To give buttons an action on a form, you can use the event. a. onblur c. onkeypress

6 b. onclick d. onchange ANS: B PTS: 1 REF: JVS Which of the following is not a Window event? a. onresize c. onscroll b. onselect d. onmove ANS: B PTS: 1 REF: JVS Which of the following is not a mouse event? a. onmousedown c. onmouseclick b. onmouseup d. onmouseout ANS: C PTS: 1 REF: JVS Which of the following is not a keyboard event? a. onkeyout c. onkeypress b. onkeydown d. none of the above ANS: A PTS: 1 REF: JVS Older web browsers used links to run JavaScript commands. a. paragraph c. hypertext b. image d. source ANS: C PTS: 1 REF: JVS A function includes its, which are values used by the function. a. terms c. ids b. parameters d. names ANS: B PTS: 1 REF: JVS is the general syntax for using anchor tags to run JavaScript. a. <a alt = "javascript:script">content</a> c. <a href = "javascript:script">content</a> b. <a href = "script">content</a> d. <a src = "javascript:script">content</a> ANS: C PTS: 1 REF: JVS To create a date object using the current date and store it in mydate, you enter. a. mydate = new Date(); b. mydate = new Time(); c. mydate = new Time(2011, 1, 24, 14, 35, 5); d. mydate = new Date(2011, 1, 24, 14, 35, 5); ANS: A PTS: 1 REF: JVS January is indicated by the number in JavaScript. a. 0 c. 4 b. 1 d. 10 ANS: A PTS: 1 REF: JVS Dates are numeric values measured in. a. milliseconds c. microseconds b. nanoseconds d. picoseconds

7 ANS: A PTS: 1 REF: JVS The method always returns the year in four digit format. a. getyear(); c. getdate(); b. getfulldate(); d. getfullyear(); ANS: D PTS: 1 REF: JVS The starting date for time calculations is. a. January 1, 1970 c. January 1, 1900 b. January 1, 1990 d. January 1, 1960 ANS: A PTS: 1 REF: JVS After the following code, what value does x contain? x = new Date("October 31, :22:05"); x = x.getminutes(); a. 31 c. 11 b. 22 d. 5 ANS: B PTS: 1 REF: JVS When the somedate variable stores the date object for "June 15, :35:28" (which is a Wednesday), the method would return a value of 3. a. somedate.getdate(); c. somedate.gettime(); b. somedate.getmonth(); d. somedate.getday(); ANS: D PTS: 1 REF: JVS To change the somedate variable s year to 2012, you enter. a. somedate.setyear(12); c. somedate.setfullyear(2012); b. somedate.setfullyear(12); d. somedate.setyear(2012); ANS: C PTS: 1 REF: JVS Which of the following includes support for daylight savings time? a. computer s operating system c. Date methods b. JavaScript d. all of the above ANS: A PTS: 1 REF: JVS Consider the following code: function showbirthday(birthday) { thisday = birthday.getdate(); thismonth = birthday.getmonth()+1; thisyear = birthday.getfullyear(); return thismonth + "/" + thisday + "/" + thisyear; } What type of parameter must birthday be? a. time object c. check object b. date object d. none of the above ANS: B PTS: 1 REF: JVS 63

8 26. The method extracts the year value from the date variable. a. extractyear() c. Year() b. getfullyear() d. thisyear() ANS: B PTS: 1 REF: JVS To make JavaScript code available to other web pages, the code should be placed in. a. the head of the document c. an external file b. an internal script tag d. a CSS file ANS: C PTS: 1 REF: JVS To tell the browser to include code from the mycode.js file, you should enter. a. <script type="text/javascript" link="mycode.js"> b. <script type="text/javascript" file="mycode.js"> c. <script type="text/javascript" href="mycode.js"> d. <script type="text/javascript" src="mycode.js"> ANS: D PTS: 1 REF: JVS In a <script> tag linking an external JavaScript file, the MIME type should be specified as. a. file/javascript c. mime/javascript b. text/javascript d. src/javascript ANS: B PTS: 1 REF: JVS To perform a calculation, a statement must include a(n). a. operator c. script file b. link d. none of the above ANS: A PTS: 1 REF: JVS A(n) operator can be used to perform simple mathematical calculations. a. conditional c. ordinal b. logical d. arithmetic ANS: D PTS: 1 REF: JVS The operator increases a value by 1 (unary operator). a. + c. ++ b. * d. ~ ANS: C PTS: 1 REF: JVS operators work on two elements in an expression. a. Binary c. Unary b. Tertiary d. Increment ANS: A PTS: 1 REF: JVS operators work on only one variable. a. Binary c. Solo b. Unary d. Increment ANS: B PTS: 1 REF: JVS 67

9 35. The most common assignment operator is the. a. += c. = b. -= d. == ANS: C PTS: 1 REF: JVS The expression to return the remainder of x divided by y would be. a. x / y c. y / x b. y % x d. x % y ANS: D PTS: 1 REF: JVS In JavaScript, the expression creates the same result as the expression x = x + y;. a. y += x c. y = x ++ y b. x = x++ d. x += y ANS: D PTS: 1 REF: JVS What does the following generic function called foo return? function foo() { var y = 3; var x = 4; y = --x; x = y++ % x; return y; } a. 4 c. 0 b. 3 d. 5 ANS: A PTS: 1 REF: JVS Which of the following calculates the difference in terms of days? a. days = (newyear - currentdate)/(1000*60*60); b. days = (newyear - currentdate)/(1000*60*24); c. days = (newyear - currentdate); d. days = (newyear - currentdate)/(1000*60*60*24); ANS: D PTS: 1 REF: JVS The can be used for performing advanced calculations and mathematical operations. a. Date object c. Library object b. Math object d. All of the above ANS: B PTS: 1 REF: JVS To change x's value to the nearest integer, you would use the following code: a. Math.round(x); c. math.round(x); b. Math.exp(x); d. math.ceil(x); ANS: A PTS: 1 REF: JVS When using a random number, the function you would least likely use to get an integer value would be.

10 a. Math.round() c. Math.ceil() b. Math.floor() d. none of the above ANS: A PTS: 1 REF: JVS The constant has the approximate value of a. Math.X c. Math.PI b. Math.E d. All of the above ANS: C PTS: 1 REF: JVS To display x with only 2 digits, you can apply the method. a. numdigits c. fixdigits b. tofixed d. tocurrency ANS: B PTS: 1 REF: JVS If x has the value , x.tofixed(3) returns what value? a c. $5.13 b. $5.135 d ANS: D PTS: 1 REF: JVS The method returns a text string with n significant digits to the left or right of the decimal point. a. toprecision c. toexponential b. tofixed d. todigits ANS: A PTS: 1 REF: JVS Given the following code: var result = 10/"A"; document.write(result); What value will be displayed? a. N/A c. NaN b. NonN d. infinity ANS: C PTS: 1 REF: JVS Which function makes sure that a number is not greater than the largest numeric value supported by JavaScript? a. isnan(value) c. iszero(value) b. isnull(value) d. isfinite(value) ANS: D PTS: 1 REF: JVS When displaying the value , JavaScript shows digits by default. a. 0 c. 4 b. 2 d. 6 ANS: D PTS: 1 REF: JVS If x has the value of 5, then to convert it to a text string, you could use. a. mystring = x; c. mystring = parsetext(x); b. mystring = x + ""; d. none of the above ANS: B PTS: 1 REF: JVS 80

11 51. converts a text string, mystring, to a number with decimal places. a. parsetext c. parsedecimal b. parseint d. parsefloat ANS: D PTS: 1 REF: JVS Which of the following returns NaN? a. parseint("the number of barrels was 12"); b. parseint("135.6"); c. parseint("3 books were read"); d. none of the above ANS: A PTS: 1 REF: JVS The general format of the conditional operator is. a. (condition) : falsevalue? truevalue c. (condition)? falsevalue : truevalue b. (condition) : truevalue : falsevalue d. (condition)? truevalue : falsevalue ANS: D PTS: 1 REF: JVS The comparison operator returns true if variables are equal. a.!= c. >= b. == d. <= ANS: B PTS: 1 REF: JVS The comparison operator returns true if variables are not equal. a. ~= c.!= b. == d. ++ ANS: C PTS: 1 REF: JVS The logical operator returns true when both expressions are true. a. c. == b. d. && ANS: D PTS: 1 REF: JVS The logical operator returns true when either expression is true. a. c. == b. d. && ANS: A PTS: 1 REF: JVS The logical operator returns true if the expression is false and false if the expression is true. a. c. && b.! d. == ANS: B PTS: 1 REF: JVS Which of the following assigns y a value of 20 if x is greater than 1 and less than 3 and 15 otherwise? a. y = (x > 1) && (x < 3) : 20? 15; c. y = (x > 1) && (x < 3)? 20 : 15; b. y = (x > 1) && (x < 3)? 15 : 20; d. y = (x > 1) (x < 3)? 20 : 15; ANS: C PTS: 1 REF: JVS 84

12 60. Using the figure above, if thishour is 21, what values will be stored in ampm and thishour after the last line of code? a. p.m., 9 c. p.m. 10 b. a.m., 9 d. a.m., 8 ANS: A PTS: 1 REF: JVS A(n) command runs after a specific amount of time. a. time-delayed c. delayed b. interval-run d. time-interval ANS: A PTS: 1 REF: JVS The general format of the command to specify that a task occur once, after some time, is. a. settime("command", interval); c. settimeout("command", delay); b. setdelay("command", interval) d. setinterval("command", delay); ANS: C PTS: 1 REF: JVS To indicate that the displaylist() method should run once, 15 milliseconds after the page loads, you would use. a. onload = "settimeout("displaylist()", 15);" b. onload = "settimeout('displaylist()', 15);" c. onload = "setinterval("displaylist()", 15);" d. onload = "setinterval('displaylist()', 15);" ANS: A PTS: 1 REF: JVS To give an identification to a command set to run once after a delay, the general syntax is. a. timeid = setinterval("command",delay); b. timeid = setdelay("command",delay); c. timeid = setidtimeout("command",delay); d. timeid = settimeout("command",delay); ANS: D PTS: 1 REF: JVS Which of the following clears only the command called mydelay that has been set to run once after 30 seconds? a. clearinterval(mydelay); c. cleartimeout(mydelay); b. clearinterval(); d. cleartimeout(); ANS: C PTS: 1 REF: JVS A(n) command instructs a browser to run the same command repeatedly. a. timed-interval c. time-delayed

13 b. interval-run d. delayed ANS: A PTS: 1 REF: JVS Which of the following clears only the command called mydelay that has been set to run every 25 seconds? a. cleartimeout(mydelay); c. clearinterval(mydelay); b. clearinterval(); d. cleartimeout(); ANS: C PTS: 1 REF: JVS To give an identification to a command set to run repeatedly after a certain amount of time, the general syntax is. a. timeid = settimeout("command",interval); b. timeid = setdelay("command",interval); c. timeid = setidtimeout("command",interval); d. timeid = setinterval("command",interval); ANS: D PTS: 1 REF: JVS Given the following code, which function starts running at 30 milliseconds? settimeout("superclock()",30); settimeout("updatemenu()",30); settimeout("performcalc()",30); a. superclock() c. performcalc() b. updatemenu() d. all of the above ANS: D PTS: 1 REF: JVS To clear all commands set to repeat, you use. a. cleartimeout() c. cleardelay() b. clearrepeat() d. clearinterval() ANS: D PTS: 1 REF: JVS 88 Case-Based Critical Thinking Questions Case 2-1 Legend Films is planning to create a page that will allow users to their video requests for the studio to add to their online video offerings. 71. In order to add the date to the form, the Web designer could use the object. a. Math c. Arithmetic b. Comparison d. Date ANS: D PTS: 1 REF: JVS 59 TOP: Critical Thinking 72. The Web designer would like to create code that could be used in each movie new release page to count down to the release. Where should he place the code to make it easy to reuse? a. in a script tag c. in an external file b. in the head of the document d. none of the above ANS: C PTS: 1 REF: JVS 64 TOP: Critical Thinking 73. External files containing JavaScript commonly use the extension.

14 a. asp c. js b. script d. php ANS: C PTS: 1 REF: JVS 65 TOP: Critical Thinking Case-Based Critical Thinking Questions Case 2-2 Carol Smith wants to create a page that would have several dynamic effects. For instance, she wants a clock that shows how long the user has been viewing a page as well as to have the page show a welcome message and a goodbye message. She also has a list of links that should run her functions to update parts of the page. 74. Carol wants to have the clock update every 10 seconds. Which method would be best for her to use to cause her script to run according to her schedule? a. setinterval c. settimeout b. setdelay d. none of the above ANS: A PTS: 1 REF: JVS 88 TOP: Critical Thinking 75. Carol will most likely use which event to display her welcome message? a. onenter c. onunload b. onexit d. onload ANS: D PTS: 1 REF: JVS 57 TOP: Critical Thinking 76. The goodbye message will most likely involve using the event. a. onenter c. onunload b. onexit d. onload ANS: C PTS: 1 REF: JVS 57 TOP: Critical Thinking 77. Since Carol is using a list of links to activate JavaScript commands, she will need to use a(n) even though it is no longer considered good design. a. hypertext link c. onclick event b. external file d. onload event ANS: A PTS: 1 REF: JVS 58 TOP: Critical Thinking Case-Based Critical Thinking Questions Case 2-3 Betty's Custom Floral Arrangements shop has an online order form. She has added some JavaScript functions to calculate how much a person has to pay before they submit the page, and now wants to add her functions to her form buttons. 78. Which event is best used for her buttons? a. ondblclick c. onclick b. onkeypress d. onmouseout ANS: C PTS: 1 REF: JVS 57 TOP: Critical Thinking 79. Betty wants to display the total from her calctotal() function in her form named results in a text box called finalamount. What will the command look like? a. results.finalamount.document.value = calctotal(); b. document.finalamount.results = calctotal();

15 c. document.finalamount.results.value = calctotal(); d. document.results.finalamount.value = calctotal(); ANS: D PTS: 1 REF: JVS 55 TOP: Critical Thinking 80. Betty gets complaints that customers are seeing NaN in certain places. What function can help her stop that from happening? a. isfin c. isnan b. isnumber d. isfinite ANS: C PTS: 1 REF: JVS 79 TOP: Critical Thinking COMPLETION 1. A(n) is an attribute added to a Web page element that specifies a program to be run in response to an event. ANS: event handler PTS: 1 REF: JVS The event handler executes when the mouse button is released. ANS: onmouseup PTS: 1 REF: JVS A(n) object is an object containing date information. ANS: date PTS: 1 REF: JVS The keyword indicates that you are creating a new object. ANS: new PTS: 1 REF: JVS To extract the day of the month from a given date object, JavaScript provides the method. ANS: getdate() getdate PTS: 1 REF: JVS The method exists for extracting the value of the current month from a date object. ANS: getmonth() getmonth

16 PTS: 1 REF: JVS The method can be used to set the time of a Date object in milliseconds since January 1, ANS: settime() settime PTS: 1 REF: JVS A(n) is a symbol used to act upon an item or a variable within a JavaScript expression. ANS: operator PTS: 1 REF: JVS The + operator belongs to a group of operators called operators, which perform simple mathematical calculations. ANS: arithmetic PTS: 1 REF: JVS The operator can be used to increase the value of a variable by 1. ANS: increment ++ PTS: 1 REF: JVS To subtract one from a variable named count before using it, you should use the operator. ANS: decrement -- PTS: 1 REF: JVS In "y = ++x;", x is before y is assigned a value. ANS: incremented PTS: 1 REF: JVS When subtracting one date from another, the answer is measured in. ANS: milliseconds PTS: 1 REF: JVS 70

17 14. A(n) statement is one that runs only when specific conditions are met. ANS: conditional PTS: 1 REF: JVS A(n) operator compares the value of one element with that of another. ANS: comparison PTS: 1 REF: JVS " x = y== 2? 45 : 50;" is an example of a(n). ANS: conditional conditional operator PTS: 1 REF: JVS The operator returns true if two expressions are true. ANS: && PTS: 1 REF: JVS If x has the value of false, then!x returns. ANS: true PTS: 1 REF: JVS A(n) command runs once after a specified amount of time passes. ANS: time-delayed PTS: 1 REF: JVS If you have six commands set with an interval of 100, they will all run at the time. ANS: same PTS: 1 REF: JVS 89 MATCHING Identify the letter of the choice that best matches the phrase or definition. a. arithmetic operator g. binary operator b. negation operator h. logical operator c. conditional operator i. comparison operator d. date object j. Math object

18 e. unary operator k. increment operator f. date method l. event handler 1. Allows you to connect several expressions 2. A ternary operator that executes a test 3. Has methods for rounding numbers 4. Requires two operands 5. Used to create expressions that have true or false values 6. Perform simple calculations 7. Changes an item's sign 8. Can be placed before or after an operand 9. Requires one operand 10. Tells browsers what code to run 11. Retrieves information from a date object 12. Created using Date(); 1. ANS: H PTS: 1 REF: JVS ANS: C PTS: 1 REF: JVS ANS: J PTS: 1 REF: JVS ANS: G PTS: 1 REF: JVS ANS: I PTS: 1 REF: JVS ANS: A PTS: 1 REF: JVS ANS: B PTS: 1 REF: JVS ANS: K PTS: 1 REF: JVS ANS: E PTS: 1 REF: JVS ANS: L PTS: 1 REF: JVS ANS: F PTS: 1 REF: JVS ANS: D PTS: 1 REF: JVS 59 ESSAY 1. Given a date object Date( June 15, 2011, 14:35:28 ) stored in a variable called Today, list six date methods to extract and display individual component values of this date object. (Note: this date is a Wednesday.) ANS: Today.getSeconds() [value is 28] Today.getMinutes() [value is 35] Today.getHours() [value is 14] Today.getDate() [value is 15] Today.getDay() [value is 3] Today.getMonth() [value is 5] Today.getFullYear() [value is 2011] Today.getTime() [value is 1,308,166,505,000]. PTS: 1 REF: JVS 59 JVS 62 TOP: Critical Thinking 2. List the assignment operators and describe each one.

19 ANS: = Assigns the value of the expression on the right to the expression on the left += Adds two expressions = Subtracts the expression on the right from the expression on the left *= Multiplies two expressions %= Calculates the remainder from dividing the expression on the left by the expression on the right. PTS: 1 REF: JVS 69 TOP: Critical Thinking 3. Write the methods to run a command after a delay, to repeat a command at set intervals, to cancel a time-delayed command, and to cancel a repeated command. ANS: To run a command after a delay, use the method: timeid = settimeout( command,delay); where command is the command to be run, delay is the delay time in milliseconds, and timeid is a variable that stores the id associated with the time-delayed command. To repeat a command at set intervals, use the method: timeid = setinterval( command, interval); where interval is the interval, in milliseconds, before the command is to run again. To cancel a time-delayed command, use the method: cleartimeout(timeid); where timeid is the id of the time-delayed command. To clear all time-delayed commands, use the method cleartimeout(). To cancel a repeated command, use the method: clearinterval(timeid); where timeid is the id of the repeated command. To clear all repeated commands, use the method clearinterval(). PTS: 1 REF: JVS 87 JVS 89 TOP: Critical Thinking

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

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

Fundamentals of Website Development

Fundamentals of Website Development Fundamentals of Website Development CSC 2320, Fall 2015 The Department of Computer Science Events handler Element with attribute onclick. Onclick with call function Function defined in your script or library.

More information

New Perspectives on Creating Web Pages with HTML. Tutorial Objectives

New Perspectives on Creating Web Pages with HTML. Tutorial Objectives New Perspectives on Creating Web Pages with HTML Tutorial 9: Working with JavaScript Objects and Events 1 Tutorial Objectives Learn about form validation Study the object-based nature of the JavaScript

More 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

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

Princeton University COS 333: Advanced Programming Techniques A Subset of JavaScript

Princeton University COS 333: Advanced Programming Techniques A Subset of JavaScript Princeton University COS 333: Advanced Programming Techniques A Subset of JavaScript Program Structure function sqr(i) var result; // Otherwise result would be global. result = i * i; //

More information

Princeton University COS 333: Advanced Programming Techniques A Subset of JavaScript

Princeton University COS 333: Advanced Programming Techniques A Subset of JavaScript Princeton University COS 333: Advanced Programming Techniques A Subset of JavaScript Program Structure function sqr(i) var result; // Otherwise result would be global. result = i * i; //

More information

JAVASCRIPT BASICS. Handling Events In JavaScript. In programing, event-driven programming could be a programming

JAVASCRIPT BASICS. Handling Events In JavaScript. In programing, event-driven programming could be a programming Handling s In JavaScript In programing, event-driven programming could be a programming paradigm during which the flow of the program is set by events like user actions (mouse clicks, key presses), sensor

More 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

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

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

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

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

Pearson Education Limited Edinburgh Gate Harlow Essex CM20 2JE England and Associated Companies throughout the world

Pearson Education Limited Edinburgh Gate Harlow Essex CM20 2JE England and Associated Companies throughout the world Pearson Education Limited Edinburgh Gate Harlow Essex CM20 2JE England and Associated Companies throughout the world Visit us on the World Wide Web at: www.pearsoned.co.uk Pearson Education Limited 2014

More 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

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

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

HTML User Interface Controls. Interactive HTML user interfaces. Document Object Model (DOM)

HTML User Interface Controls. Interactive HTML user interfaces. Document Object Model (DOM) Page 1 HTML User Interface Controls CSE 190 M (Web Programming), Spring 2007 University of Washington Reading: Sebesta Ch. 5 sections 5.1-5.7.2, Ch. 2 sections 2.9-2.9.4 Interactive HTML user interfaces

More 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

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

Key features. Nothing to do with java It is the Client-side scripting language Designed to add interactivity to HTML pages

Key features. Nothing to do with java It is the Client-side scripting language Designed to add interactivity to HTML pages Javascript Key features Nothing to do with java It is the Client-side scripting language Designed to add interactivity to HTML pages (DHTML): Event-driven programming model AJAX Great example: Google Maps

More 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

Outline. Lecture 4: Document Object Model (DOM) What is DOM Traversal and Modification Events and Event Handling

Outline. Lecture 4: Document Object Model (DOM) What is DOM Traversal and Modification Events and Event Handling Outline Lecture 4: Document Object Model (DOM) What is DOM Traversal and Modification Events and Event Handling Wendy Liu CSC309F Fall 2007 1 2 Document Object Model (DOM) An defined application programming

More information

3Lesson 3: Functions, Methods and Events in JavaScript Objectives

3Lesson 3: Functions, Methods and Events in JavaScript Objectives 3Lesson 3: Functions, Methods and Events in JavaScript Objectives By the end of this lesson, you will be able to: 1.3.1: Use methods as. 1.3.2: Define. 1.3.3: Use data type conversion methods. 1.3.4: Call.

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

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

Want to add cool effects like rollovers and pop-up windows?

Want to add cool effects like rollovers and pop-up windows? Chapter 10 Adding Interactivity with Behaviors In This Chapter Adding behaviors to your Web page Creating image rollovers Using the Swap Image behavior Launching a new browser window Editing your behaviors

More information

Unit 3. Operators. School of Science and Technology INTRODUCTION

Unit 3. Operators. School of Science and Technology INTRODUCTION INTRODUCTION Operators Unit 3 In the previous units (unit 1 and 2) you have learned about the basics of computer programming, different data types, constants, keywords and basic structure of a C program.

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

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

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

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

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

Introduction. Following are the types of operators: Unary requires a single operand Binary requires two operands Ternary requires three operands

Introduction. Following are the types of operators: Unary requires a single operand Binary requires two operands Ternary requires three operands Introduction Operators are the symbols which operates on value or a variable. It tells the compiler to perform certain mathematical or logical manipulations. Can be of following categories: Unary requires

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

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

JavaScript Handling Events Page 1

JavaScript Handling Events Page 1 JavaScript Handling Events Page 1 1 2 3 4 5 6 7 8 Handling Events JavaScript JavaScript Events (Page 1) An HTML event is something interesting that happens to an HTML element Can include: Web document

More information

CSC Javascript

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

More information

JavaScript CS 4640 Programming Languages for Web Applications

JavaScript CS 4640 Programming Languages for Web Applications JavaScript CS 4640 Programming Languages for Web Applications 1 How HTML, CSS, and JS Fit Together {css} javascript() Content layer The HTML gives the page structure and adds semantics Presentation

More information

JavaScript CS 4640 Programming Languages for Web Applications

JavaScript CS 4640 Programming Languages for Web Applications JavaScript CS 4640 Programming Languages for Web Applications 1 How HTML, CSS, and JS Fit Together {css} javascript() Content layer The HTML gives the page structure and adds semantics Presentation

More information

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

Photo from DOM

Photo from  DOM Photo from http://www.flickr.com/photos/emraya/2861149369/ DOM 2 DOM When a browser reads an HTML file, it must interpret the file and render it onscreen. This process is sophisticated. Fetch Parse Flow

More 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

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

About the Author. Liability

About the Author. Liability II Liability The purpose of this book is to provide basic guides for people interested in JavaScript. Although every effort and care has been taken to make the information as accurate as possible, the

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

link document.getelementbyid("coffee").style.borderwidth = "0px" document.getelementbyid("tea").style.borderwidth = "10px"

link document.getelementbyid(coffee).style.borderwidth = 0px document.getelementbyid(tea).style.borderwidth = 10px function coffeeinfo() document.getelementbyid('p3').innerhtml = "the word 'coffee' was at one time a term for wine, but was. " document.getelementbyid('p3').style.color

More information

Introduction to JavaScript, Part 2

Introduction to JavaScript, Part 2 Introduction to JavaScript, Part 2 Luka Abrus Technology Specialist, Microsoft Croatia Interaction In the first part of this guide, you learned how to use JavaScript, how to write code and how to see if

More 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

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

GO - OPERATORS. This tutorial will explain the arithmetic, relational, logical, bitwise, assignment and other operators one by one.

GO - OPERATORS. This tutorial will explain the arithmetic, relational, logical, bitwise, assignment and other operators one by one. http://www.tutorialspoint.com/go/go_operators.htm GO - OPERATORS Copyright tutorialspoint.com An operator is a symbol that tells the compiler to perform specific mathematical or logical manipulations.

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

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

Coding in JavaScript functions

Coding in JavaScript functions Coding in JavaScript functions A function contains code that will be executed by an event or by a call to the function. You may call a function from anywhere within a page (or even from other pages if

More information

Beijing , China. Keywords: Web system, XSS vulnerability, Filtering mechanisms, Vulnerability scanning.

Beijing , China. Keywords: Web system, XSS vulnerability, Filtering mechanisms, Vulnerability scanning. 2017 International Conference on Computer, Electronics and Communication Engineering (CECE 2017) ISBN: 978-1-60595-476-9 XSS Vulnerability Scanning Algorithm Based on Anti-filtering Rules Bo-wen LIU 1,

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

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

C ITS 1231 Web Tec hnolog ies. JavaScript: Document, Event, Date objects

C ITS 1231 Web Tec hnolog ies. JavaScript: Document, Event, Date objects C ITS 1231 Web Tec hnolog ies JavaScript: Document, Event, Date objects D oc um ent O bjec t JavaScript can interact with HTML page elements via the Document Object. The Document Object is accessed via

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 7 Functions and Randomness 1 Predefined Functions recall: in

More information

JavaScript Tutorial for Programmers

JavaScript Tutorial for Programmers JavaScript Tutorial for Programmers This JavaScript tutorial is aimed primarily at those who have had at least some exposure to another programming language. It is not our purpose here to cover the basic

More information

TEXTAREA NN 2 IE 3 DOM 1

TEXTAREA NN 2 IE 3 DOM 1 778 TEXTAREA Chapter 9DOM Reference TEXTAREA NN 2 IE 3 DOM 1 The TEXTAREA object reflects the TEXTAREA element and is used as a form control. This object is the primary way of getting a user to enter multiple

More information

Basic operators, Arithmetic, Relational, Bitwise, Logical, Assignment, Conditional operators. JAVA Standard Edition

Basic operators, Arithmetic, Relational, Bitwise, Logical, Assignment, Conditional operators. JAVA Standard Edition Basic operators, Arithmetic, Relational, Bitwise, Logical, Assignment, Conditional operators JAVA Standard Edition Java - Basic Operators Java provides a rich set of operators to manipulate variables.

More information

A Balanced Introduction to Computer Science, 3/E David Reed, Creighton University 2011 Pearson Prentice Hall ISBN

A Balanced Introduction to Computer Science, 3/E David Reed, Creighton University 2011 Pearson Prentice Hall ISBN A Balanced Introduction to Computer Science, 3/E David Reed, Creighton University 2011 Pearson Prentice Hall ISBN 978-0-13-216675-1 Chapter 7 Functions and Randomness 1 Predefined Functions recall: in

More information

JavaScript and XHTML. Prof. D. Krupesha, PESIT, Bangalore

JavaScript and XHTML. Prof. D. Krupesha, PESIT, Bangalore JavaScript and XHTML Prof. D. Krupesha, PESIT, Bangalore Why is JavaScript Important? It is simple and lots of scripts available in public domain and easy to use. It is used for client-side scripting.

More 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

Installation and Configuration Manual

Installation and Configuration Manual Installation and Configuration Manual IMPORTANT YOU MUST READ AND AGREE TO THE TERMS AND CONDITIONS OF THE LICENSE BEFORE CONTINUING WITH THIS PROGRAM INSTALL. CIRRUS SOFT LTD End-User License Agreement

More information

4. Inputting data or messages to a function is called passing data to the function.

4. Inputting data or messages to a function is called passing data to the function. Test Bank for A First Book of ANSI C 4th Edition by Bronson Link full download test bank: http://testbankcollection.com/download/test-bank-for-a-first-book-of-ansi-c-4th-edition -by-bronson/ Link full

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

DC71 INTERNET APPLICATIONS JUNE 2013

DC71 INTERNET APPLICATIONS JUNE 2013 Q 2 (a) With an example show text formatting in HTML. The bold text tag is : This will be in bold. If you want italics, use the tag, as follows: This will be in italics. Finally, for

More information

Operators. Java operators are classified into three categories:

Operators. Java operators are classified into three categories: Operators Operators are symbols that perform arithmetic and logical operations on operands and provide a meaningful result. Operands are data values (variables or constants) which are involved in operations.

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

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

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

Canvas & Brush Reference. Source: stock.xchng, Maarten Uilenbroek

Canvas & Brush Reference. Source: stock.xchng, Maarten Uilenbroek Canvas & Brush Reference Source: stock.xchng, Maarten Uilenbroek Canvas Hierarchy WACanvas WAHtmlCanvas WARenderCanvas WAStaticHtmlCanvas Brush Hierarchy WABrush WACompound WADateInput WATimeInput WATagBrush

More information

Functions, Randomness and Libraries

Functions, Randomness and Libraries Functions, Randomness and Libraries 1 Predefined Functions recall: in mathematics, a function is a mapping from inputs to a single output e.g., the absolute value function: -5 5, 17.3 17.3 in JavaScript,

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

Lesson 3: Basic Programming Concepts

Lesson 3: Basic Programming Concepts 3 ICT Gaming Essentials Lesson 3: Basic Programming Concepts LESSON SKILLS After completing this lesson, you will be able to: Explain the types and uses of variables and operators in game programming.

More information

Review: Exam 1. Your First C++ Program. Declaration Statements. Tells the compiler. Examples of declaration statements

Review: Exam 1. Your First C++ Program. Declaration Statements. Tells the compiler. Examples of declaration statements Review: Exam 1 9/20/06 CS150 Introduction to Computer Science 1 1 Your First C++ Program 1 //*********************************************************** 2 // File name: hello.cpp 3 // Author: Shereen Khoja

More information

JSF - H:INPUTSECRET. Class name of a validator that s created and attached to a component

JSF - H:INPUTSECRET. Class name of a validator that s created and attached to a component http://www.tutorialspoint.com/jsf/jsf_inputsecret_tag.htm JSF - H:INPUTSECRET Copyright tutorialspoint.com The h:inputsecret tag renders an HTML input element of the type "password". JSF Tag

More information

حميد دانشور H_danesh_2000@yahoo.com 1 JavaScript Jscript VBScript Eg 2 JavaScript: the first Web scripting language, developed by Netscape in 1995 syntactic similarities

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

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

Multiple Choice Questions, COPA, Semester-2. Dr.V.Nagaradjane

Multiple Choice Questions, COPA, Semester-2. Dr.V.Nagaradjane Multiple Choice Questions, COPA, Semester-2 DrVNagaradjane December 25, 2017 ii Author: DrVNagaradjane Contents 1 Javascript 1 11 Algorithms 1 12 Flowcharts 1 13 Web servers 2 14 Features of web servers

More information

JavaScript: Events, the DOM Tree, jquery and Timing

JavaScript: Events, the DOM Tree, jquery and Timing JavaScript: Events, the DOM Tree, jquery and Timing CISC 282 October 11, 2017 window.onload Conflict Can only set window.onload = function once What if you have multiple files for handlers? What if you're

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

UNIT - III. Every element in a document tree refers to a Node object. Some nodes of the tree are

UNIT - III. Every element in a document tree refers to a Node object. Some nodes of the tree are UNIT - III Host Objects: Browsers and the DOM-Introduction to the Document Object Model DOM History and Levels-Intrinsic Event Handling- Modifying Element Style-The Document Tree-DOM Event Handling- Accommodating

More information

Full file at Excel Chapter 2 - Formulas, Functions, Formatting, and Web Queries

Full file at   Excel Chapter 2 - Formulas, Functions, Formatting, and Web Queries Excel Chapter 2 - Formulas, Functions, Formatting, and Web Queries MULTIPLE CHOICE 1. To start a new line in a cell, press after each line, except for the last line, which is completed by clicking the

More information

Operators. Lecture 3 COP 3014 Spring January 16, 2018

Operators. Lecture 3 COP 3014 Spring January 16, 2018 Operators Lecture 3 COP 3014 Spring 2018 January 16, 2018 Operators Special built-in symbols that have functionality, and work on operands operand an input to an operator Arity - how many operands an operator

More information

DOM Primer Part 2. Contents

DOM Primer Part 2. Contents DOM Primer Part 2 Contents 1. Event Programming 1.1 Event handlers 1.2 Event types 1.3 Structure modification 2. Forms 2.1 Introduction 2.2 Scripting interface to input elements 2.2.1 Form elements 2.2.2

More 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

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

Chapter 2 Working with Data Types and Operators

Chapter 2 Working with Data Types and Operators JavaScript, Fourth Edition 2-1 Chapter 2 Working with Data Types and Operators At a Glance Instructor s Manual Table of Contents Overview Objectives Teaching Tips Quick Quizzes Class Discussion Topics

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

Outcomes Week 2 Overview Describe the inputs, activities, and outputs of each step in the software development life cycle. Describe arithmetic, relati

Outcomes Week 2 Overview Describe the inputs, activities, and outputs of each step in the software development life cycle. Describe arithmetic, relati ITEC 136 Business Programming Concepts Week 02, Part 01 Overview 1 Week 2 Overview Week 1 review HTML documents Document Type Definition Elements (tags) Attributes Entities Inline and external JavaScript

More information

JAVASCRIPT BASICS. JavaScript Math Functions. The Math functions helps you to perform mathematical tasks

JAVASCRIPT BASICS. JavaScript Math Functions. The Math functions helps you to perform mathematical tasks JavaScript Math Functions Functions The Math functions helps you to perform mathematical tasks in a very way and lot of inbuilt mathematical functions which makes the programmers life easier. Typical example

More information

A Balanced Introduction to Computer Science, 3/E David Reed, Creighton University 2011 Pearson Prentice Hall ISBN

A Balanced Introduction to Computer Science, 3/E David Reed, Creighton University 2011 Pearson Prentice Hall ISBN A Balanced Introduction to Computer Science, 3/E David Reed, Creighton University 2011 Pearson Prentice Hall ISBN 978-0-13-216675-1 Chapter 5 JavaScript and User Interaction 1 Text Boxes HTML event handlers

More information