Summary

This document provides notes on JavaScript, including its use in web pages, variables, and functions. It offers examples and explanations of various concepts to aid in learning the programming language.

Full Transcript

JAVASCRIPT Notes JAVASCRIPT JavaScript is the scripting language of the Web. JavaScript is used in millions of Web pages to add functionality, validate forms, detect browsers, and much more. Introduction to JavaScript JavaScript is used in millions of Web pages to improve the design, validate fo...

JAVASCRIPT Notes JAVASCRIPT JavaScript is the scripting language of the Web. JavaScript is used in millions of Web pages to add functionality, validate forms, detect browsers, and much more. Introduction to JavaScript JavaScript is used in millions of Web pages to improve the design, validate forms, detect browsers, create cookies, and much more. JavaScript is the most popular scripting language on the Internet, and works in all major browsers, such as Internet Explorer, Mozilla Firefox, and Opera. 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 directly into HTML pages  JavaScript is an interpreted language (means that scripts execute without preliminary compilation)  Everyone can use JavaScript without purchasing a license Java and JavaScript are two completely different languages in both concept and design! Java (developed by Sun Microsystems) is a powerful and much more complex programming language - in the same category as C and C++. What can a JavaScript Do ?  JavaScript gives HTML designers a programming tool - HTML authors are normally not programmers, but JavaScript is a scripting language with a very simple syntax! Almost anyone can put small "snippets" of code into their HTML pages  JavaScript can put dynamic text into an HTML page - A JavaScript statement like this: document.write("" + name + "") can write a variable text into an HTML page  JavaScript can react to events - A JavaScript can be set to execute when something happens, like when a page has finished loading or when a user clicks on an HTML element  JavaScript can read and write HTML elements - A JavaScript can read and change the content of an HTML element  JavaScript can be used to validate data - A JavaScript can be used to validate form data before it is submitted to a server. This saves the server from extra processing  JavaScript can be used to detect the visitor's browser - A JavaScript can be used to detect the visitor's browser, and - depending on the browser - load another page specifically designed for that browser By – Prof Harshal V Patil Page 1 JAVASCRIPT Notes  JavaScript can be used to create cookies - A JavaScript can be used to store and retrieve information on the visitor's computer. JavaScript Variables Variables are "containers" for storing information. JavaScript variables are used to hold values or expressions. A variable can have a short name, like x, or a more descriptive name, like carname. Rules for JavaScript variable names:  Variable names are case sensitive (y and Y are two different variables)  Variable names must begin with a letter or the underscore character Note: Because JavaScript is case-sensitive, variable names are case-sensitive. Example A variable's value can change during the execution of a script. You can refer to a variable by its name to display or change its value. var firstname; firstname="Welcome"; document.write(firstname); document.write(""); firstname="XYZ"; document.write(firstname); The script above declares a variable, assigns a value to it, displays the value, change the value, and displays the value again. Output : Welcome XYZ The script above declares a variable, assigns a value to it, displays the value, change the value, and displays the value again. By – Prof Harshal V Patil Page 2 JAVASCRIPT Notes Declaring (Creating) JavaScript Variables Creating variables in JavaScript is most often referred to as "declaring" variables. You can declare JavaScript variables with the var statement: var x; var carname; After the declaration shown above, the variables are empty (they have no values yet). However, you can also assign values to the variables when you declare them: var x=5; var carname="Scorpio"; After the execution of the statements above, the variable x will hold the value 5, and carname will hold the value Scorpio. Note: When you assign a text value to a variable, use quotes around the value. Assigning Values to Undeclared JavaScript Variables If you assign values to variables that have not yet been declared, the variables will automatically be declared. These statements: x=5; carname="Scorpio"; have the same effect as: var x=5; var carname="Scorpio"; Redeclaring JavaScript Variables If you redeclare a JavaScript variable, it will not lose its original value. var x=5; var x; By – Prof Harshal V Patil Page 3 JAVASCRIPT Notes After the execution of the statements above, the variable x will still have the value of 5. The value of x is not reset (or cleared) when you redeclare it. By – Prof Harshal V Patil Page 4 JAVASCRIPT Notes DataTypes  Numbers - are values that can be processed and calculated. You don't enclose them in quotation marks. The numbers can be either positive or negative.  Strings - are a series of letters and numbers enclosed in quotation marks. JavaScript uses the string literally; it doesn't process it. You'll use strings for text you want displayed or values you want passed along.  Boolean (true/false) - lets you evaluate whether a condition meets or does not meet specified criteria.  Null - is an empty value. null is not the same as 0 -- 0 is a real, calculable number, whereas null is the absence of any value. Data Types TYPE EXAMPLE Numbers Any number, such as 17, 21, or 54e7 Strings "Greetings!" or "Fun" Boolean Either true or false Null A special keyword for exactly that – the null value (that is, nothing) JavaScript Arithmetic As with algebra, you can do arithmetic operations with JavaScript variables: y=x-5; z=y+5; JavaScript Operators The operator = is used to assign values. The operator + is used to add values. The assignment operator = is used to assign values to JavaScript variables. The arithmetic operator + is used to add values together. y=5; z=2; x=y+z; By – Prof Harshal V Patil Page 5 JAVASCRIPT Notes The value of x, after the execution of the statements above is 7. JavaScript Arithmetic Operators Arithmetic operators are used to perform arithmetic between variables and/or values. Given that y=5, the table below explains the arithmetic operators: Operator Description Example Result + Addition x=y+2 x=7 - Subtraction x=y-2 x=3 * Multiplication x=y*2 x=10 / Division x=y/2 x=2.5 % Modulus (division remainder) x=y%2 x=1 ++ Increment x=++y x=6 -- Decrement x=--y x=4 JavaScript Assignment Operators Assignment operators are used to assign values to JavaScript variables. Given that x=10 and y=5, the table below explains the assignment operators: Operator Example Same As Result = x=y x=5 += x+=y x=x+y x=15 -= x-=y x=x-y x=5 *= x*=y x=x*y x=50 /= x/=y x=x/y x=2 %= x%=y x=x%y x=0 The + Operator Used on Strings The + operator can also be used to add string variables or text values together. To add two or more string variables together, use the + operator. txt1="What a very"; txt2="nice day"; txt3=txt1+txt2; By – Prof Harshal V Patil Page 6 JAVASCRIPT Notes After the execution of the statements above, the variable txt3 contains "What a verynice day". To add a space between the two strings, insert a space into one of the strings: txt1="What a very "; txt2="nice day"; txt3=txt1+txt2; or insert a space into the expression: txt1="What a very"; txt2="nice day"; txt3=txt1+" "+txt2; After the execution of the statements above, the variable txt3 contains: "What a very nice day" Adding Strings and Numbers Look at these examples: x=5+5; document.write(x); x="5"+"5"; document.write(x); x=5+"5"; document.write(x); x="5"+5; document.write(x); The rule is: If you add a number and a string, the result will be a string. JavaScript Comparison and Logical Operators Comparison and Logical operators are used to test for true or false. By – Prof Harshal V Patil Page 7 JAVASCRIPT Notes Comparison Operators Comparison operators are used in logical statements to determine equality or difference between variables or values. Given that x=5, the table below explains the comparison operators: Operator Description Example == is equal to x==8 is false === is exactly equal to (value and type) x===5 is true x==="5" is false != is not equal x!=8 is true > is greater than x>8 is false < is less than x= is greater than or equal to x>=8 is false 10 && time Let's take a look and see what happened here: By – Prof Harshal V Patil Page 28 JAVASCRIPT Notes 1. On the first line, we created a new instance of the array bannerImg, and gave it three data elements. (Remember, we are only making a copy of the Array object here.) 2. Next, we created two variables: newBanner, which has a beginning value of zero; and totalBan, which returns the length of the array (the total number of elements contained in the array). 3. Then we created a function named cycleBan. This function will be used to create a loop to cycle the images. a. We set the newBanner variable to be increased each time the function cycles. (Review: By placing the increment operator [" ++ "] after the variable [the "operand"], the variable is incremented only after it returns its current value to the script. For example, its beginning value is "0", so in the first cycle it will return a value of "0" to the script and then its value will be increased by "1".) b. When the value of the newBanner variable is equal to the variable totalBan (which is the length of the array), it is then reset to "0". This allows the images to start the cycle again, from the beginning. c. The next statement uses the Document Object Method (DOM - we'll be taking a look at that soon) to display the images on the Web page. Remember, we use the dot operator to access the properties of an object. We also read the statement backwards, i.e., "take the element from the array bannerImg, that is specified by the current value of the variable newBanner, and place it in the src attribute located in the element with the name attribute of banner, which is located in the document object." d. We then used the setTimeout function to tell the script how long to display each image. This is always measured in milliseconds so, in this case, the function cycleBan is called every 3,000 milliseconds (i.e., every 3 seconds). 4. Finally, we used the window.onload statement to execute the function cycleBan as soon as the document is loaded. There are a total of five properties for the Array object. In addition to the length property listed above, the others are: 1. constructor: Specifies the function that creates an object's prototype. 2. index: Only applies to JavaScript arrays created by a regular expression match. 3. input: Only applies to JavaScript arrays created by a regular expression match. 4. prototype: Used to add properties or methods. By – Prof Harshal V Patil Page 29 JAVASCRIPT Notes The other properties listed here are either more advanced or seldom used. For now, we'll stick to the basics. Javascript Object Hierarchy Hierarchy Objects Object Properties Methods Event Handlers Window defaultStatus alert onLoad frames blur onUnload opener close onBlur parent confirm onFocus scroll focus self open status prompt top clearTimeout window setTimeout History length back none forward go Navigator appCodeName javaEnabled none appName appVersion mimeTypes plugins userAgent document alinkColor clear none (the onLoad and onUnload event handlers anchors close belong to the Window object. applets open area write bgColor writeln cookie fgColor forms images lastModified linkColor links location referrer title By – Prof Harshal V Patil Page 30 JAVASCRIPT Notes vlinkColor image border none none complete height hspace lowsrc name src vspace width form action submit onSubmit elements reset onReset encoding FileUpload method name target text defaultValue focus onBlur name blur onCharge type select onFocus value onSelect Built-in Objects Array length join none reverse sort xx Date none getDate none getDay getHours getMinutes getMonth getSeconds getTime getTimeZoneoffset getYear parse prototype setDate setHours setMinutes setMonth setSeconds setTime By – Prof Harshal V Patil Page 31 JAVASCRIPT Notes setYear toGMTString toLocaleString UTC String length anchor Window prototype big blink bold charAt fixed fontColor fontSize indexOf italics lastIndexOf link small split strike sub substring sup toLowerCase toUpperCase JavaScript Array Object The Array object is used to store multiple values in a single variable. Create an Array The following code creates an Array object called myCars: var myCars=new Array(); There are two ways of adding values to an array (you can add as many values as you need to define as many variables you require). 1: var myCars=new Array(); myCars="Saab"; myCars="Volvo"; myCars="BMW"; By – Prof Harshal V Patil Page 32 JAVASCRIPT Notes You could also pass an integer argument to control the array's size: var myCars=new Array(3); myCars="Saab"; myCars="Volvo"; myCars="BMW"; 2: var myCars=new Array("Saab","Volvo","BMW"); Note: If you specify numbers or true/false values inside the array then the type of variables will be numeric or Boolean instead of string. Access an Array You can refer to a particular element in an array by referring to the name of the array and the index number. The index number starts at 0. The following code line: document.write(myCars); will result in the following output: Saab Modify Values in an Array To modify a value in an existing array, just add a new value to the array with a specified index number: myCars="Opel"; Now, the following code line: document.write(myCars); will result in the following output: Opel JavaScript Date Object By – Prof Harshal V Patil Page 33 JAVASCRIPT Notes Create a Date Object The Date object is used to work with dates and times. The following code create a Date object called myDate: var myDate=new Date() Note: The Date object will automatically hold the current date and time as its initial value! Set Dates We can easily manipulate the date by using the methods available for the Date object. In the example below we set a Date object to a specific date (14th January 2010): var myDate=new Date(); myDate.setFullYear(2010,0,14); And in the following example we set a Date object to be 5 days into the future: var myDate=new Date(); myDate.setDate(myDate.getDate()+5); Note: If adding five days to a date shifts the month or year, the changes are handled automatically by the Date object itself! Compare Two Dates The Date object is also used to compare two dates. The following example compares today's date with the 14th January 2010: var myDate=new Date(); myDate.setFullYear(2010,0,14); var today = new Date(); if (myDate>today) { alert("Today is before 14th January 2010"); } else { alert("Today is after 14th January 2010"); } JavaScript Math Object By – Prof Harshal V Patil Page 34 JAVASCRIPT Notes Math Object The Math object allows you to perform mathematical tasks. The Math object includes several mathematical constants and methods. Syntax for using properties/methods of Math: var pi_value=Math.PI; var sqrt_value=Math.sqrt(16); Note: Math is not a constructor. All properties and methods of Math can be called by using Math as an object without creating it. Mathematical Constants JavaScript provides eight mathematical constants that can be accessed from the Math object. These are: E, PI, square root of 2, square root of 1/2, natural log of 2, natural log of 10, base-2 log of E, and base-10 log of E. You may reference these constants from your JavaScript like this: Math.E Math.PI Math.SQRT2 Math.SQRT1_2 Math.LN2 Math.LN10 Math.LOG2E Math.LOG10E Mathematical Methods In addition to the mathematical constants that can be accessed from the Math object there are also several methods available. The following example uses the round() method of the Math object to round a number to the nearest integer: document.write(Math.round(4.7)); The code above will result in the following output: 5 By – Prof Harshal V Patil Page 35 JAVASCRIPT Notes The following example uses the random() method of the Math object to return a random number between 0 and 1: document.write(Math.random()); The code above can result in the following output: 0.4218824567728053 The following example uses the floor() and random() methods of the Math object to return a random number between 0 and 10: document.write(Math.floor(Math.random()*11)); The code above can result in the following output: 4 JavaScript String Object String object The String object is used to manipulate a stored piece of text. Examples of use: The following example uses the length property of the String object to find the length of a string: var txt="Hello world!"; document.write(txt.length); The code above will result in the following output: 12 The following example uses the toUpperCase() method of the String object to convert a string to uppercase letters: var txt="Hello world!"; document.write(txt.toUpperCase()); The code above will result in the following output: HELLO WORLD! By – Prof Harshal V Patil Page 36 JAVASCRIPT Notes Window Object The Window object is the top level object in the JavaScript hierarchy. The Window object represents a browser window. A Window object is created automatically with every instance of a or tag. IE: Internet Explorer, F: Firefox, O: Opera. Window Object Collections Collection Description IE F O frames[] Returns all named frames in the window 4 1 9 Window Object Properties Property Description IE F O closed Returns whether or not a window has been closed 4 1 9 defaultStatus Sets or returns the default text in the statusbar of the window 4 No 9 document See Document object 4 1 9 history See History object 4 1 9 length Sets or returns the number of frames in the window 4 1 9 location See Location object 4 1 9 name Sets or returns the name of the window 4 1 9 opener Returns a reference to the window that created the window 4 1 9 outerHeight Sets or returns the outer height of a window No 1 No outerWidth Sets or returns the outer width of a window No 1 No pageXOffset Sets or returns the X position of the current page in relation to the No No No upper left corner of a window's display area pageYOffset Sets or returns the Y position of the current page in relation to the No No No upper left corner of a window's display area parent Returns the parent window 4 1 9 personalbar Sets whether or not the browser's personal bar (or directories bar) should be visible scrollbars Sets whether or not the scrollbars should be visible self Returns a reference to the current window 4 1 9 status Sets the text in the statusbar of a window 4 No 9 statusbar Sets whether or not the browser's statusbar should be visible toolbar Sets whether or not the browser's tool bar is visible or not (can only be set before the window is opened and you must have UniversalBrowserWrite privilege) top Returns the topmost ancestor window 4 1 9 By – Prof Harshal V Patil Page 37 JAVASCRIPT Notes Window Object Methods Method Description IE F O alert() Displays an alert box with a message and an OK button 4 1 9 blur() Removes focus from the current window 4 1 9 clearInterval() Cancels a timeout set with setInterval() 4 1 9 clearTimeout() Cancels a timeout set with setTimeout() 4 1 9 close() Closes the current window 4 1 9 confirm() Displays a dialog box with a message and an OK and a Cancel 4 1 9 button createPopup() Creates a pop-up window 4 No No focus() Sets focus to the current window 4 1 9 moveBy() Moves a window relative to its current position 4 1 9 moveTo() Moves a window to the specified position 4 1 9 open() Opens a new browser window 4 1 9 print() Prints the contents of the current window 5 1 9 prompt() Displays a dialog box that prompts the user for input 4 1 9 resizeBy() Resizes a window by the specified pixels 4 1 9 resizeTo() Resizes a window to the specified width and height 4 1.5 9 scrollBy() Scrolls the content by the specified number of pixels 4 1 9 scrollTo() Scrolls the content to the specified coordinates 4 1 9 setInterval() Evaluates an expression at specified intervals 4 1 9 setTimeout() Evaluates an expression after a specified number of milliseconds 4 1 9 Document Object The Document object represents the entire HTML document and can be used to access all elements in a page. The Document object is part of the Window object and is accessed through the window.document property. IE: Internet Explorer, F: Firefox, O: Opera, W3C: World Wide Web Consortium (Internet Standard). Document Object Collections Collection Description IE F O W3C anchors[] Returns a reference to all Anchor objects in the 4 1 9 Yes document forms[] Returns a reference to all Form objects in the 4 1 9 Yes document images[] Returns a reference to all Image objects in the 4 1 9 Yes document links[] Returns a reference to all Area and Link objects in 4 1 9 Yes By – Prof Harshal V Patil Page 38 JAVASCRIPT Notes the document Document Object Properties Property Description IE F O W3C body Gives direct access to the element cookie Sets or returns all cookies associated with the 4 1 9 Yes current document domain Returns the domain name for the current document 4 1 9 Yes lastModified Returns the date and time a document was last 4 1 No No modified referrer Returns the URL of the document that loaded the 4 1 9 Yes current document title Returns the title of the current document 4 1 9 Yes URL Returns the URL of the current document 4 1 9 Yes Document Object Methods Method Description IE F O W3C close() Closes an output stream opened with the 4 1 9 Yes document.open() method, and displays the collected data getElementById() Returns a reference to the first object with the 5 1 9 Yes specified id getElementsByName() Returns a collection of objects with the specified 5 1 9 Yes name getElementsByTagName() Returns a collection of objects with the specified 5 1 9 Yes tagname open() Opens a stream to collect the output from any 4 1 9 Yes document.write() or document.writeln() methods write() Writes HTML expressions or JavaScript code to a 4 1 9 Yes document writeln() Identical to the write() method, with the addition 4 1 9 Yes of writing a new line character after each expression History Object The History object is actually a JavaScript object, not an HTML DOM object. The History object is automatically created by the JavaScript runtime engine and consists of an array of URLs. These URLs are the URLs the user has visited within a browser window. The History object is part of the Window object and is accessed through the window.history property. IE: Internet Explorer, F: Firefox, O: Opera. By – Prof Harshal V Patil Page 39 JAVASCRIPT Notes History Object Properties Property Description IE F O length Returns the number of elements in the history list 4 1 9 History Object Methods Method Description IE F O back() Loads the previous URL in the history list 4 1 9 forward() Loads the next URL in the history list 4 1 9 go() Loads a specific page in the history list 4 1 9 Form Object The Form object represents an HTML form. For each instance of a tag in an HTML document, a Form object is created. IE: Internet Explorer, F: Firefox, O: Opera, W3C: World Wide Web Consortium (Internet Standard). Form Object Collections Collection Description IE F O W3C elements[] Returns an array containing each element in the form 5 1 9 Yes Form Object Properties Property Description IE F O W3C acceptCharset Sets or returns a list of possible character-sets for the form data No No No Yes action Sets or returns the action attribute of a form 5 1 9 Yes enctype Sets or returns the MIME type used to encode the content of a 6 1 9 Yes form id Sets or returns the id of a form 5 1 9 Yes length Returns the number of elements in a form 5 1 9 Yes method Sets or returns the HTTP method for sending data to the server 5 1 9 Yes name Sets or returns the name of a form 5 1 9 Yes target Sets or returns where to open the action-URL in a form 5 1 9 Yes Standard Properties Property Description IE F O W3C className Sets or returns the class attribute of an element 5 1 9 Yes dir Sets or returns the direction of text 5 1 9 Yes lang Sets or returns the language code for an element 5 1 9 Yes title Sets or returns an element's advisory title 5 1 9 Yes By – Prof Harshal V Patil Page 40 JAVASCRIPT Notes Form Object Methods Method Description IE F O W3C reset() Resets the values of all elements in a form 5 1 9 Yes submit() Submits a form 5 1 9 Yes Image Object The Image object represents an embedded image. For each instance of an tag in an HTML document, an Image object is created. IE: Internet Explorer, F: Firefox, O: Opera, W3C: World Wide Web Consortium (Internet Standard). Image Object Properties Property Description IE F O W3C align Sets or returns how to align an image according to the 5 1 9 Yes surrounding text alt Sets or returns an alternate text to be displayed, if a browser 5 1 9 Yes cannot show an image border Sets or returns the border around an image 4 1 9 Yes complete Returns whether or not the browser has finished loading the 4 1 9 No image height Sets or returns the height of an image 4 1 9 Yes hspace Sets or returns the white space on the left and right side of the 4 1 9 Yes image id Sets or returns the id of the image 4 1 9 Yes isMap Returns whether or not an image is a server-side image map 5 1 9 Yes longDesc Sets or returns a URL to a document containing a description 6 1 9 Yes of the image lowsrc Sets or returns a URL to a low-resolution version of an image 4 1 9 No name Sets or returns the name of an image 4 1 9 Yes src Sets or returns the URL of an image 4 1 9 Yes useMap Sets or returns the value of the usemap attribute of an client- 5 1 9 Yes side image map vspace Sets or returns the white space on the top and bottom of the 4 1 9 Yes image width Sets or returns the width of an image 4 1 9 Yes Standard Properties Property Description IE F O W3C className Sets or returns the class attribute of an element 5 1 9 Yes title Sets or returns an element's advisory title 5 1 9 Yes By – Prof Harshal V Patil Page 41 JAVASCRIPT Notes Area Object The Area object represents an area of an image-map (An image-map is an image with clickable regions). For each instance of an tag in an HTML document, an Area object is created. IE: Internet Explorer, F: Firefox, O: Opera, W3C: World Wide Web Consortium (Internet Standard). Area Object Properties Property Description IE F O W3C accessKey Sets or returns the keyboard key to access an area 5 1 No Yes alt Sets or returns an alternate text to be displayed, if a browser 5 1 9 Yes cannot show an area coords Sets or returns the coordinates of a clickable area in an image- 5 1 9 Yes map hash Sets or returns the anchor part of the URL in an area 4 1 No No host Sets or returns the hostname and port of the URL in an area 4 1 No No href Sets or returns the URL of a link in an image-map 4 1 9 Yes id Sets or returns the id of an area 4 1 9 Yes noHref Sets or returns whether an area should be active or inactive 5 1 9 Yes pathname Sets or returns the pathname of the URL in an area 4 1 9 No protocol Sets or returns the protocol of the URL in an area 4 1 9 No search Sets or returns the query string part of the URL in an area 4 1 9 No shape Sets or returns the shape of an area in an image-map 5 1 9 Yes tabIndex Sets or returns the tab order for an area 5 1 9 Yes target Sets or returns where to open the link-URL in an area 4 1 9 Yes Standard Properties Property Description IE F O W3C className Sets or returns the class attribute of an element 5 1 9 Yes dir Sets or returns the direction of text 5 1 9 Yes lang Sets or returns the language code for an element 5 1 9 Yes title Sets or returns an element's advisory title 5 1 9 Yes Navigator Object The Navigator object is actually a JavaScript object, not an HTML DOM object. The Navigator object is automatically created by the JavaScript runtime engine and contains information about the client browser. IE: Internet Explorer, F: Firefox, O: Opera. By – Prof Harshal V Patil Page 42 JAVASCRIPT Notes Navigator Object Collections Collection Description IE F O plugins[] Returns a reference to all embedded objects in the document 4 1 9 Navigator Object Properties Property Description IE F O appCodeName Returns the code name of the browser 4 1 9 appMinorVersion Returns the minor version of the browser 4 No No appName Returns the name of the browser 4 1 9 appVersion Returns the platform and version of the browser 4 1 9 browserLanguage Returns the current browser language 4 No 9 cookieEnabled Returns a Boolean value that specifies whether cookies are 4 1 9 enabled in the browser cpuClass Returns the CPU class of the browser's system 4 No No onLine Returns a Boolean value that specifies whether the system is in 4 No No offline mode platform Returns the operating system platform 4 1 9 systemLanguage Returns the default language used by the OS 4 No No userAgent Returns the value of the user-agent header sent by the client to 4 1 9 the server userLanguage Returns the OS' natural language setting 4 No 9 Navigator Object Methods Method Description IE F O javaEnabled() Specifies whether or not the browser has Java enabled 4 1 9 taintEnabled() Specifies whether or not the browser has data tainting enabled 4 1 9 ZIP CODE VALIDATION By – Prof Harshal V Patil Page 43 JAVASCRIPT Notes Zip: Free JavaScripts provided by The JavaScript Source By – Prof Harshal V Patil Page 45

Use Quizgecko on...
Browser
Browser