CS2361–Internet & Java 2.1

Introduction What is JavaScript? Discuss its features ¾ JavaScript is a client-side scripting language and is the defacto scripting language for most web-based application. ¾ It is used to enhance the functionality and appearance of Web pages by making it more dynamic, interactive and creating web pages on the fly. ¾ JavaScript is interpreted by the browser. ¾ Statements are terminated by a ; but is not required. ¾ JavaScript standard is defined by ECMA to which is fully compliant whereas IE complies with a modified version known as JScript. ¾ The ¾ The script is executed either when page is loaded or when given event occurs. ¾ The script will not be executed if it is disabled in the browser environment. ¾ For browsers that do not understand javascript, the entire script code is enclosed within xhtml comment. ¾ Script can also be placed in a separate file and pointed by src attribute. ¾ JavaScript is an object-oriented language and has a set of pre-defined objects (document, window, form, etc) to access and manipulate XHTML elements. ¾ An object's attribute is used to set/read data, whereas a method provides service. ¾ Javascripthas utility classes such as date, math, string, etc which can be instantiated. List some common JavaScript objects and its usage? Object Description document Used to access XHTML body elements such as links, images, etc form It is used to access XHTML form elements in the current web page frame It corresponds to a frame in the window history Holds the history of sites previously visited location Holds information about the page URL navigator Refers to the browser itself window Refers to the current browser window http://cseannauniv.blogspot.in Vijai Anand CS2361–Internet & Java 2.2

List some methods of commonly used objects? ¾ document.writeʊwrites text to the current web page ¾ document.writelnʊwrites text to the current page and adds a newline character ¾ history.goʊnavigates the browser to a location in the browser history ¾ window.alertʊdisplays a message dialog ¾ window.promptʊdisplays an user input dialog ¾ window.openʊopens a new browser window ¾ window.closeʊCloses the current window List some properties of commonly used objects? ¾ document.linkcolorʊto set color of unvisited hyperlinks ¾ document.bgcolorʊto set background color of the current page ¾ document.lastmodifiedʊto know when the page was last modified ¾ document.titleʊtitle of the current page ¾ location.hostnameʊname of the ISP host ¾ navigator.appNameʊName of the browser. How are comments specified in JavaScript? ¾ A single line comment is placed after //. ¾ A multiline comment is placed within /* and */. List the rules for identifiers in JavaScript. ¾ Identifiers are declared using var statement and is loosely typed ¾ Identifier can contain alphabet, digits, underscore or dollar sign ¾ The first character must be an alphabet, underscore(_) or dollar sign ($) ¾ Identifiers are case sensitive and white spaces are not allowed ¾ Some valid identifiers are Sum, sum, total_marks, _valid, $value List the operators supported by JavaScript. ¾ Arithmetic: + - * / % ¾ Increment / Decrement operator: ++-- ¾ Combination assignment operators such as += *= /= etc ¾ Relational: <<= >>= == != ¾ ҏLogical: && || ! ¾ Bitwise operator: & | >><< ^etc ¾ Operator precedence are of order () ++ -- * / % + - <<= >>= == != ?: = += -= *= /= %= Give the syntax of Javascript's writeln method and explain with an example. document.writeln("string"); ¾ The document object represents the XHTML document currently displayed. ¾ The writeln method of document object instructs the browser to display the string and places cursor on the next line, whereas the write method displays further output on the same line. ¾ The + operator is used to concatenate strings. If string contains XHTML element or escape sequence, then it is interpreted by the browser accordingly. http://cseannauniv.blogspot.in Vijai Anand CS2361–Internet & Java 2.3

writeln method List the escape sequences supported by JavaScript. ¾ The escape sequences are characters preceded by a \ (backslash) as in C. ¾ Used in output statement to provide special function. Commonly used ones are\n (newline) \t(tab) \" (quotes) \' (apostrophe), etc. How are variables declared in JavaScript? ¾ Variables in Javascript are declared using var keyword. ¾ Variables in Javascript are loosely typed, i.e., type of the variable is not specified in the declaration statement. Briefly explain prompt & alert dialog window with an example. window.alert("plaintext"); variable = window.prompt("plaintext", "default"); ¾ The prompt method of window object is used to display a user prompt dialog that displays a message and textbox for user input. ¾ An optional default value can be included. ¾ When user enters the value and presses OK, the value entered is stored in the variable as a string. ¾ If the user clicks Cancel or enters an incorrect type of data, error results. ¾ The alert method of window object is an information dialog used to display information to the user. It is closed by clicking the OK button.

An Addition Program http://cseannauniv.blogspot.in Vijai Anand CS2361–Internet & Java 2.4

Give the usage of parseInt function in JavaScript? ¾ The parseInt function is used to convert the string number to integer for processing. ¾ If the string is not a pure number, then NaN (Not a Number) error results. Control Structures – Selection Define algorithm. ¾ An algorithm is a step-by-step solution for a given problem. ¾ It is generally written in lay-man's language. Give the characteristics of a Pseudocode. ¾ Pseudocode is an artificial and informal language that helps programmers to develop algorithms. ¾ It is written in plain English, convenient and user friendly. ¾ It describes executable statements but not declarations. ¾ It is not a computer programming language. List some javascript keywords. Break case continue default while delete do else void for function if in var new return switch this typeof with Explain if statement(or) single selection statement in detail with an example. Syntax Flowchart if(condition) { statements }

¾ The if structure is a single-entry/single-exit structure. ¾ The if statement evaluates a condition (relational or logical expression), whose outcome is either true or false. ¾ If the condition is true, then next statement or statements enclosed within {} is executed otherwise not.

if statement

Write if statement for the following: i. Display leap year if month is February and it has 29 days. ii. Display "Counter Closed" if it is non-banking hours if (day==29 && month=="February") document.writeln("Leap year"); if (hour < 8 || hour >17) document.writeln("Counter Closed"); Explain if-else statement(or) double selection in Javascript with an example Syntax FlowChart if(condition) { statements_1 } else { statements_2 } ¾ The if statement is extended to include an optional else part. ¾ The if-else statement is a two-way decision making. ¾ If the condition is true, then set of statements following if is executed, otherwise set of statements following else is executed.

if-else

What is ternary operator? Give an example. http://cseannauniv.blogspot.in Vijai Anand CS2361–Internet & Java 2.6

¾ JavaScript provides a conditional operator known as ternary operator ?: ¾ Ternary operator provides a concise way of representing an if-else statement. Condition?statement1:statement2; ¾ If condition holds true, then statement1 is executed, else statement2 is executed. document.writeln(a>b ? "A is big" : "B is big" ); ¾ Ternary operators can be nested. Explain nested else-if (or) if-else structure with an example. ¾ Nested if-else structure checks multiple condition by placing an if-else as part of another if-else. ¾ The nested structure can contain an optional else part. ¾ Each boolean expression is evaluated in order. If true, then the corresponding sets of statements are executed and control is transferred out of the structure. ¾ When all conditions fail, then the last optional else part if present is executed.

else-ifladder

Explain multiple selection using switch with the help of an example. ¾ A variable or expression may require to be tested separately for a set of values and different actions needed for each value.

http://cseannauniv.blogspot.in Vijai Anand CS2361–Internet & Java 2.7

¾ JavaScript provides switch, multiple-selection structure to handle such decision making instead of the complex nested if else structure. ¾ In switch, there are test cases with an optional default case. ¾ Each case block is terminated by a break statement except for default case. Syntax Flowchart switch(expression) { case value1: statements break; case value2: statements break; .... case valueN: statements break; default: statements } ¾ The test expression is matched with the constant in each case. ¾ When a match is found, the set of statements following case is executed until break statement is encountered. ¾ The break statement causes an exit from the switch structure. ¾ When none of the case constant matches, the statements following default is executed. ¾ When a set of statement is common for multiple cases, then they are listed consecutively without any other statement. The last one has the case block

Switch-case

Repetitive Control Structures Compare while and do … while loop in detail? ¾ The while loop allows a set of statements to be repeatedly executed until the condition remains true. ¾ The while loop is an entry controlled loop, i.e., condition is tested prior to executing body of the loop. ¾ The body of the loop is executed repeatedly as long as condition remains true. ¾ When the condition becomes false, control is transferred to the next statement after loop. ¾ The minimum number of iteration (repetition) for a while loop is 0. ¾ While loop can used in either sentinel-controlled or counter-controlled repetition. Syntax Flowchart while(condition) { body of the loop }

While http://cseannauniv.blogspot.in Vijai Anand CS2361–Internet & Java 2.9

do-while ¾ The do while structure is an exit controlled loop. ¾ The loop-continuation condition is tested after body of the loop is executed. ¾ The body of the loop is executed at least once. ¾ Control is transferred out of the loop when the condition becomes false. Syntax Flowchart do { body of the loop } while(condition);

Do-while

Discuss for loop in detail? ¾ The for structure details a counter-controlled repetition.

Syntax Flowchart for(Initialize; Test; Increment) { body of the loop }

http://cseannauniv.blogspot.in Vijai Anand CS2361–Internet & Java 2.10

¾ The for structure contains three parts namely initialization, test condition and increment/decrement separated by a ; (semicolon). ¾ Initialization part is used to initialize a counter variable. It is executed once. ¾ Condition is tested and body of the loop is executed if condition holds true ¾ For successive iterations, the counter is incremented/decremented and then the condition is checked. ¾ Incrementing/decrementing counter variable ensures the loop to be finite. ¾ The loop will be executed minimum 0 times.

for ¾ Multiple variables can be initialized and are separated by comma. Similarly multiple counters can be modified. for(i=0,j=n; i<=n ; i++,j--) ¾ None of the three parts in a for loop is mandatory. o Counters can be initialized before the loop. o Modification of counter variable can be done within the loop. o If test condition is missing, then it may lead to infinite loop. In such case, condition needs to be introduced within the loop with a break statement. for( ; ; ) What is nesting? ¾ A loop within the body of another loop is known as nesting. ¾ The loops could be of different type or of the same type. ¾ There is no limit on the level of nesting. while ( ) { … for ( ) { … } } http://cseannauniv.blogspot.in Vijai Anand CS2361–Internet & Java 2.11

Distinguish break and continue statement? ¾ The break statement causes an exit from the structure (while, for, do-while and switch) in which it is placed. If it is placed in a innermost loop, then control is transferred out of the innermost loop only. ¾ The continue statement causes control to skip rest of the loop and to continue with the next iteration.

break and continue ¾ break and continue keywords can be followed by a label known as labeled break and labeled continue statements. ¾ In such cases control is transferred to the label. The jump could be either a forward or backward jump. http://cseannauniv.blogspot.in Vijai Anand CS2361–Internet & Java 2.12

Function Distinguish between function and methods in JavaScript? ¾ Functions in JavaScript could be either predefined or user-defined whereas methods are predefined functions and bound to specific object. ¾ Methods are invoked using an object whereas functions do not require it. ¾ Both of them accomplish a well-defined task. List advantages and disadvantages of functions? ¾ Facilitates modular programming ¾ Eliminates code redundancy and ensures software reusability ¾ Easy to understand, debug and test, i.e., manageable program development ¾ Function call incurs overhead such as saving current address for returning control and state of variables, loading function address for transfer of control, etc. Explain user-defined function with an example.

function fn-name(parameter-list) { Local variable declaration Function body return expr; } ¾ User-defined functions are defined using the function keyword. It may optionally take a set of arguments or parameters. ¾ A function is invoked by a function call. ¾ Control is transferred back to next statement after calling point when a return statement or end of the function is encountered. ¾ Function parameters and variables declared within the function are of local scope. ¾ The return statement may or may not return a value to the calling point.

Fibonacci function http://www.csesannauniv.blogspot.in Vijai Anand CS2361–Internet & Java 2.13

Distinguish between local variable and global variable? ¾ A global identifier is not declared within any function and its scope is the entire script ¾ A local identifier is declared within a function and could be accessed within that function only. Local variables are destroyed when control exits the function.

Define recursive function. Explain with an example. ¾ A recursive function is a function that calls itself either directly or indirectly. ¾ A recursive function has the ability to solve simple or base case only. ¾ If the recursive function is called for a base case, then it returns a result. Otherwise a recursive call is made with a slightly simpler version of the original problem. ¾ Recursion step normally includes return statement. ¾ The recursion step executes while the original call to the function is still open, which may result in further recursion calls. ¾ Recursion attempts to reduce the complexity of the problem till it reaches a base case. For example, n! = n×(n-1)!, (n-1)! = (n-1)× (n-2)! and so on, until n=1.

Recursive Function http://www.csesannauniv.blogspot.in Vijai Anand CS2361–Internet & Java 2.14

Bring out the differences between recursion and iteration. ¾ Iteration uses a repetitive structure (for, while, do-while), whereas recursion uses selection structure (if, if-else). ¾ Iteration explicitly uses a repetition structure, whereas recursion uses repeated function calls. ¾ Iteration terminates when loop continuation condition fails, whereas recursion terminates when it comes across base case. ¾ Both iteration and recursion can be infinite. List the drawbacks of recursive mechanism. ¾ Recursion results in more overhead due to repeated function calls ¾ Recursion is expensive in terms of memory space and processor time ¾ Recursion cannot be applied for all problems. It is inefficient for fibonacci series. Give some pre-defined functions in JavaScript and their usage. Function Description isNaN Returns true if the argument is a number otherwise false parseInt Converts string to an integer. If first character is not a digit, then NaN is returned otherwise numeric portion of the string is converted. parseFloat Converts string to a float. If first character is not a digit, then NaN is returned otherwise numeric portion of the string is converted. eval Executes javascript code stored as a string dynamically. Arrays Define array. Explain with an example in JavaScript. ¾ An array is a collection of homogeneous elements (of the same type but need not be). ¾ Contiguous memory locations are reserved for array elements. ¾ It is defined using the Array object. The new operator allocates memory dynamically for the required number of elements specified as size. var array_name = new Array(size); ¾ Array elements have the same array name but are distinguished by a positional integer known as subscript (eg. a[5]) ¾ Array subscript for the first element is always 0. For array of size n, the subscript is in the range 0 to n-1. ¾ The size of an array can be determined using the length property. ¾ Arrays can also be initialized at the time of declaration. The initial values are provided as arguments separated by comma. Size of array is n, if there are n values. var array_name = new Array(value1, value2, …, valueN); ¾ Array input/output/processing is generally done using for loop. ¾ Arrays in javascript are dynamic, i.e., size grows at run-time to store values.

Array Sum

What is for/in loop? Give an example. ¾ The for/in loop is used specifically with arrays and objects. ¾ Javascript automatically determines number of elements in the array. ¾ It means for each element in the array, eliminating the need to know array size and counter-controlled repetition.

for (var i in arr) document.writeln(arr[i] + " "); Distinguish between pass-by-value and pass-by-reference? ¾ Two way of passing parameters to functions are pass-by-value and pass-by-reference. ¾ In pass-by-value method, a copy of actual parameter's value is passed to the function. Any changes made within the function do not affect the actual parameter since the function arguments have local scope only. ¾ In pass-by-reference, instead of value, array address or object reference is passed. Any change to the function argument affects the actual parameter. ¾ Pass-by-reference is used when large amount of data needs to be passed onto function or when multiple values need to be returned. Write a javascript program to sort an array. ¾ Arrays in javascript are sorted using the sort method. ¾ The sort method by default does string comparison based on ASCII values. ¾ To sort numbers, a comparator function is passed as an argument to the sort method. ¾ Comparator function takes two arguments and returns the difference between them.

Sorting

Write a javascript program to search an element in the array using Binary search method. ¾ In linear search, each element is checked in sequence from the first element. Access to an element depends on how farther is its offset. The array can be an unsorted one. ¾ Linear search requires more number of comparisons and is time-consuming. ¾ To search a large sorted list, an efficient method known as binary search is used. ¾ In binary search, the middle element of the array is compared with the search key, If both are same then position of the element is returned. ¾ Otherwise, the range is bisected by half. o If middle element > search key, then algorithm is repeated on the upper half (0 to middle-1), otherwise lower half (middle+1 to last). o Repeat until the element is located or not found. ¾ Thus binary search eliminates half of the elements in each iteration. ¾ The maximum number of comparison for any sorted array is exponent of the first power of 2 greater than the number of elements in the array.

Binary Search

What is multi-dimensional array? Write a javascript program to add two matrices. ¾ Two dimensional (multi-dimensional) arrays are represented as rows and columns. ¾ In a two-dimensional array, each row has a set of associated columns. Number of columns need not be the same for all rows, can vary. ¾ In javascript for 2D array, the number of rows is declared first. In turn, each row is used to specify number of columns. var array_name = new Array(row_dimension); array_name[row_subscript] = new Array(col_dimension); ¾ To traverse 2D array, nested for loop is used. Outermost loop represents row index and the innermost loop is used to traverse columns of the current row.

Matrix Addition Objects List and explain the methods of Math object with an example. ¾ The Math object has methods used to perform common calculation.

Method Description Example abs(x) absolute value of x abs(7.2) is 7.2 abs(-5.6) is 5.6 ceil(x) rounds x to the smallest integer not less than x ceil( 9.2) is 10.0 ceil(-9.8) is -9.0 floor(x) rounds x to the largest integer not greater than x floor( 9.2) is 9.0 floor(-9.8) is -10.0 max(x, y) larger value of x and y max(2.3, 12.7) is 12.7 min(x, y) smaller value of x and y min(2.3, 12.7) is 2.3 pow(x, y) x raised to power y pow(2.0, 7.0) is 128.0 round(x) rounds x to the closest integer round(9.75) is 10 round(9.25) is 9 cos(x) trigonometric cosine of x (x value in radians) cos(0.0) is 1.0 sqrt(x) square root of x sqrt(9.0) is 3.0 log(x) natural logarithm of x http://www.csesannauniv.blogspot.in Vijai Anand CS2361–Internet & Java 2.19

¾ The Math object also defines several constants. Some are:

Constant Description Value Math.PI ʌ value Approx. 3.142 Math.LN10 Natural logarithm of 10 Approx. 2.302 Math.E Euler's constant Approx. 2.718 Math.SQRT2 Square root of 2.0 Approx 1.414

Throw of a Die

Define string. List the methods of String object with an example and explain. ¾ String is a series of characters (letters, digits and special characters) within quotes. ¾ In javascript, relational operators can be used on strings. The operator + is used to concatenate strings. ¾ The String object provides methods to manipulate strings. Commonly used are:

Method Description charAt(index) Returns the character at the specified index. Index of first character is 0. charCodeAt(index) Returns the Unicode value of the character at the specified index. concat(string) Returns a concatenation of invoking and argument string. The invoking string is not modified. indexOf(substring, Searches for the first occurrence of substring starting from position index index) in the string. It returns the starting index of substring in the source string or –1 if not found. lastIndexOf( Searches for the last occurrence of substring starting from position index substring, index) substr(start, Returns the string containing length characters from index start in the length) given string. toLowerCase() Returns a string with letters in lowercase. toUpperCase() Returns a string with letters in uppercase. () Returns the source string as enclosed within element. Does not work in http://www.csesannauniv.blogspot.in Vijai Anand CS2361–Internet & Java 2.20

Method Description fixed() Returns the source string as enclosed within element. link(url) Returns the source string as enclosed within element. The argument url specifies the document linked to. strike() Returns the source string as enclosed within element. sub() Returns the string as subscript. sup() Returns the string in superscript.

String object

Explain the methods of Date object and its usage with an example. ¾ Javascript Date object provides methods for date and time manipulation. ¾ Date and time processing can be based either on local time zone or Universal Coordinated Time (UTC).

Method Description getDate() Returns a number from 1 to 31 representing day of the month. getUTCDate() getDay() Returns a number from 0 (Sunday) to 6 (Saturday) representing getUTCDay() day of the week. getMonth() Returns a number from 0 (January) to 11 (December) getUTCMonth() representing the month. getFullYear() Returns the year as a four-digit number. getUTCFullYear() getHours() Returns a number from 0 to 23 representing hours. getUTCHours() getMinutes() Returns a number from 0 to 59 representing minutes. getUTCMinutes() getSeconds() Returns a number from 0 to 59 representing seconds. getUTCSeconds()

http://www.csesannauniv.blogspot.in Vijai Anand CS2361–Internet & Java 2.21

Method Description setDate(val) Sets day of the month (1 to 31) in local time or UTC. setUTCDate(val) setMonth(m,d) Sets the month in local time or UTC. Other arguments are setMonth(m,d) optional and taken from Date object if not provided. setFullYear(y,m,d) Sets year in local time or UTC. Other arguments are optional setUTCFullYear(y,m,d) and taken from Date object if not provided. setHours(h,m,s,ms) Sets hours in local time or UTC. Other arguments are optional setUTCHours(h,m,s,ms) and taken from Date object if not provided. setMinutes(m,s,ms) Sets minutes in local time or UTC. Other arguments are setUTCMinutes(m,s,ms) optional and taken from Date object if not provided. setSeconds(s,ms) Sets seconds in local time or UTC. Other arguments are setUTCSeconds(s,ms) optional and taken from Date object if not provided. toString() Returns a string representation of the date and time in local or toUTCString() UTC. ¾ When a instance of Date object is created without arguments, it fetches date/time details from the system clock. Otherwise user can specify the set of parameters. var date_var = new Date(y,m,d,h,m,s,ms);

Date/Time Methods

List the methods and properties of document object. Method/Property Description write(string) Writes a given string to the XHTML document. writeln(string) Writes a given string to the XHTML document and adds a newline character at the end. document.cookie This property returns a string containing the values of all cookies stored on user’s computer for the current document.

http://www.csesannauniv.blogspot.in Vijai Anand CS2361–Internet & Java 2.22

Method/Property Description document.lastModified This property returns the date and time when the document was last modified.

List the important methods and properties of window object. Give an example.

Method / Property Description open(url,name,options) Opens a new window with specified url and the features are set as given by the string as option. prompt(prompt, default) Displays a dialog box asking the user for input. The text of the dialog is prompt, and the default value is set to default. close() Closes the current window and deletes its object from memory. focus() This method gives focus to the window (i.e., puts the window in the foreground, on top of any other open browser windows). window.document This property contains the document object representing the document currently inside the window. window.closed This property contains a boolean value that is set to true if the window is closed, and false if it is not.

Window Object

Main window

Select features for the child window
Address Bar Scroll Bars Resizable

What is cookie? ¾ Cookie is a text file (max. 4KB) stored on the client system and contains information about the client as name-value pairs. ¾ Cookies are stored during browsing session and are accessed using cookie property. ¾ Cookies have an expiration date and set using expires property. ¾ Cookies can be disabled by the browser due to fears about privacy invasion. Briefly explain the Boolean object. ¾ Boolean object is used as wrapper for boolean value (true/false). ¾ Javascript automatically creates a Boolean object to store a boolean value. ¾ It can also be explicitly created as var bool_var = new Boolean(bool_value); ¾ If bool_value takes value false, 0, null, Number.NAN or "" then the variable assumes false, otherwise true. ¾ The Boolean object has two methods namely toString() and valueOf(). List the methods and properties of Number object. ¾ JavaScript automatically creates Number objects to store numeric values in the program. It can also be explicitly created.

Method / Property Description toString(radix) Returns number as a string. The optional radix argument specifies the number’s base. Number.MAX_VALUE This property represents the largest value that can be stored, i.e., approx. 1.79E+308 Number.MIN_VALUE This property represents the smallest value that can be stored, approx. 2.22E–308 Number.NaN This property represents not a number—result of an arithmetic expression that does not result in a number Number.NEGATIVE_INFINITY This property represents a value < -Number.MAX_VALUE. Number.POSITIVE_INFINITY This property represents a value > Number.MAX_VALUE

http://www.csesannauniv.blogspot.in Vijai Anand CS2361–Internet & Java 2.24

DHTML

Define DHTML. ¾ Dynamic HTML (DHTML) is a combination of XHTML, JavaScript and CSS. ¾ With DHTML every element in a Web page can be manipulated ¾ DHTML is not a standard. Hence its implementation varies from browser to browser. List the key features of DHTML. ¾ Dynamic ContentʊWeb page content can be added, deleted or changed on the fly ¾ Dynamic StylesʊChanging element styles such as font, color, etc., without a server roundtrip ¾ Absolute positioningʊUsing CSS positioning, element locations can be changed to created animated effects. ¾ DOMʊAll page elements are represented as objects for easy manipulation ¾ ScriptletsʊScripts that function as components in Web application. ¾ ActiveX controlsʊVisual effects and transitions ¾ BehaviorsʊSeparate code from data ¾ Data bindingʊPages that display, sort, filter and update data from a database. List some events based on which scripts can be executed. Event Executed when … onblur When an element loses focus onchange When a control changes its value onclick When the user clicks over the element ondblclick When the user double clicks over the element onfocus When the element receives focus onload When a body element has finished loading onmousedown When the mouse button is depressed over the element onmouseover When the mouse is moved over the element onmouseup When the mouse button is released over the element onreset When a user clicks on the reset button of a form onselect When the user selects some text onsubmit When a user submits a form onunload When navigating to another page Discuss the features of DHTML in detail with an example. Dynamic Content ¾ An element can be referenced using the id attribute. ¾ The innerText property of an element refers to text enclosed by that element.

Dynamic Content

Enter mobile number to receive alerts

Dynamic Style ¾ The style object is used to set most CSS properties such as color, backgroundColor, fontFamily, borderWidth, etc.

Dynamic Style

Font color:
Fill color:
Sample Text
http://www.csesannauniv.blogspot.in Vijai Anand CS2361–Internet & Java 2.26

Dynamic Position

http://www.csesannauniv.blogspot.in Vijai Anand