Learn Java
Working with JSP Sessions
Working with JSP Sessions In this JSP tutorial, you will learn about JSP session object methods, getCreationTime, getLastAccessedTime, getId, invalidate(), getMaxInactiveInterval, setMaxInactiveInterval(), removeAttribute(String name) and setAttribute(String, object). This section details the syntax, usage, example and explanation of more session object methods, such as: getCreationTime getLastAccessedTime getId invalidate() getMaxInactiveInterval setMaxInactiveInterval() removeAttribute(String name) setAttribute(String, object) getCreationTime: The getCreationTime method of session object is used to return the session created time. The returned time value would be in milliseconds, the time value is midnight January 1, 1970 GMT. General syntax of getCreationTime of session object is as follows: session.getCreationTime() The above method returns…
JavaScript Objects
JavaScript Objects Object oriented Programming in an important aspect of JavaScript. It is possible to use built-in objects available in JavaScript. It is also possible for a JavaScript programmer to define his own objects and variable types. In this JavaScript tutorial, you will learn how to make use of built-in objects available in JavaScript. Built-in objects in JavaScript: Some of the built-in objects available in JavaScript are: Date Math String Array Object Of the above objects, the most widely used one is the String object. Objects are nothing but special kind of data. Each object has Properties and Methods associated…
JavaScript String Object
JavaScript String Object In this JavaScript tutorial, you will learn about String Object, purpose of string object in JavaScript, purpose of string object, indexof method, lastIndexOf method and substring method along with syntax and example. Purpose of String Object in JavaScript: The main purpose of String Object in JavaScript is for storing text. General method of using String Object is to declare a variable and assign a string, in other words a text to the variable. var exf="Welcome" assigns the text Welcome to the variable exf defined. We have seen in earlier section that some of the methods used in…
JavaScript Date Object
JavaScript Date Object In this JavaScript tutorial, you will learn about date object and methods of date object explained along with syntax and example. JavaScript Date Object: Usage of Date Object: Date object of Java Script is used to work with date and times. General syntax for defining Date object in Java Script is as follows: var variablename=new Date( ) In the above new is a keyword which creates an instance of object and Date() defines variablename as Date Object. For example: var exf=new Date( ) In the above example, variable exf is defined as Date object which has current…
JavaScript Math Object
JavaScript Math Object In this JavaScript tutorial, you will learn about Math Object, usage, properties and methods of math object along with syntax and examples. Usage of Math Object: JavaScript Math object is used to perform mathematical tasks. But unlike the String and the Date object which requires defining the object, Math object need not be defined. Math object in JavaScript has two main attributes: Properties Methods Properties of Math Object: The JavaScript has eight mathematical values and this can be accessed by using the Math Object. The eight mathematical values are: E PI square root of 2 denoted as…
JavaScript Windows Object Properties Part II
JavaScript Windows Object Properties Part II In this JavaScript tutorial, you will learn about screenX, screenY, screenLeft and screenTop, top, length, frames, opener, parent and window property of Window object along with syntax and examples. screenX: This property screenX returns the x coordinate of the window relative to the user’s monitor screen. In other words this property namely ScreenX indicates in pixels the distance that the new window is placed from the left side of the screen horizontally. This property is a read onlywrite property. General syntax for using this screenY property of Window object is as follows: window.screenX screenY:…
JavaScript Windows Object Properties Part I
JavaScript Windows Object Properties Part I In this JavaScript tutorial, you will learn about Windows Object properties namely personalbar, statusbar, scrollbar, toolbar property of Window object, pageXOffset, pageYOffset, innerwidth, innerheight, outerwidth and outerheight. personalbar Property of Window Object: The personalbar property of a Window Object relates to the browser’s personal or directory bars. This is the region where the user has easy access to certain bookmarks. The personalbar property has the default property set as true, meaning visible, and can also be set to false, meaning hidden, as per the programmer’s requirement. The personalbar Property of a Window Object is…
JavaScript Window Object Timeout Methods
JavaScript Window Object Timeout Methods In this JavaScript tutorial, you will learn about setTimeout(), clearTimeout() and open() methods of window object along with syntax, usage and examples for each method. setTimeout(): The setInterval() method of Window object is used to call a function or evaluate an expression at specified intervals. The setTimeout() method of a window object performs in a similar manner. In contrast to the setInterval() method, the setTimeout() method of window object is used to call a function or evaluate an expression after a specified number of milliseconds. The setTimeout() method helps schedule the expression or function for…
JavaScript Document Object Methods Part II
JavaScript Document Object Methods Part II In this JavaScript tutorial, you will learn about document object methods – getElementsByTagName, getSelection, handleEvent, releaseEvents, routeEvent, write, writeln along with syntax, examples and brief explanation. getElementsByTagName: The the getElementsTagName() method returns a collection of objects with the specified TagNAME given in argument. The programmer can enter an asterisk ("*") as the parameter to retrieve a list of all elements within the document. The general syntax for using the getElementsByName method of document object is as follows: document.getElementsByTagName(tagname) for example: <html> <head> <script type="text/javascript"> function Exforinput() { var test=document.getElementsByTagName("input");…
JavaScript Document Object Methods Part I
JavaScript Document Object Methods – Part I In this JavaScript tutorial, you will learn about methods of document object along with syntax and examples. This section covers captureEvents, open, close, getElementById, getElementsByName methods with explanations for each method. Methods of document Object: captureEvents: The captureEvents method instructs the document to capture and handle all events of a particular type. The general syntax for using the captureEvents method of document object is as follows: document.captureEvents(eventType) The list of eventType in an earlier section of this tutorial called Event Handler in JavaScript. For example: document.captureEvents(Event.MOUSEMOVE); In the above, the MouseMove event is…
JavaScript History Object Properties and Methods
JavaScript History Object Properties and Methods In this JavaScript tutorial, you will learn about history object properties and methods, length, current, next, previous properties, back(), forward() and go() methods along with syntax and examples. The history property has the return value as history object, which is an array of history items having details of the URL’s visited from within that window. Also, note that the History object is a JavaScript object and not an HTML DOM object. General syntax of history property of Window Object: window.history The JavaScript runtime engine automatically creates this object. An introduction on the history object and the…
JavaScript Elements and Embed Objects
JavaScript Elements and Embed Objects In this JavaScript tutorial, you will learn about browser objects – elements and embed, properties of elements object, length, type, embed object, properties of embed object along with syntax and examples. elements object: The elements object is used in JavaScript to access all form elements such as fields or buttons that are present or embedded within a form. Since each element inside the form is stored as an array element within the array elements[], the user can make use of the loop concept to access any individual element within a form in JavaScript. For example:…
JavaScript OnError Event
JavaScript OnError Event In this JavaScript tutorial, you will learn about onerror event, how to use onerror event along with syntax and example. Using onerror event: The onerror event fires when a page has a script error. This onerror event occurs in JavaScript when an image or document causes an error during loading. This does not mean that it is a browser error. This event handler will only be triggered by a JavaScript error, not a browser error. The general syntax of onerror event is as follows: onerror=functionname() function functionname(msg,file_loc,line_num) { var1=msg; var2=file_loc; var3=line_num; ……… return true/false; } The onerror…
JavaScript Event Handler
JavaScript Event Handler In this JavaScript tutorial, you will learn about using event handlers along with events for each HTML tag. Using Event Handler in JavaScript: Event Handlers are used in JavaScript by placing the name of the event handler inside the HTML tag associated with object. This is followed by =’JavaScript code’, the code in JavaScript which must execute when the event fires. The events for each HTML tag are as follows: <A> click (onClick) mouseOver (onMouseOver) mouseOut (onMouseOut) <AREA> mouseOver (onMouseOver) mouseOut (onMouseOut) <BODY> blur (onBlur) error (onError) focus (onFocus) load (onLoad) unload (onUnload) <FORM> submit (onSubmit) reset…
JavaScript Exception Handling – Part II
JavaScript Exception Handling – Part II In this JavaScript tutorial, you will learn about exception handling viz. try…catch..finally statement and nested try…catch statements along with syntax and examples. try…catch..finally Statement: JavaScript has a finally statement that can be used as an optional construct along with try..catch statements. The finally construct placed in a try…catch construct is an optional statement. When the finally statement is placed in a try…catch construct, it always runs following the try…catch structure. The general syntax of a try…catch..finally statement is as follows: try { ………… //Block of code which is to be tested for errors ……………
JavaScript Exception Handling – Part I
JavaScript Exception Handling – Part I In this JavaScript tutorial, you will learn about Exception Handling, Catching errors in JavaScript, Using try..catch statement and throw in JavaScript along with syntax and examples. It is impossible for a programmer to write a program without errors. Programming languages include exceptions, or errors, that can be tracked and controlled. Exception handling is a very important concept in programming technology. In earlier versions of JavaScript, the exceptions handling was not so efficient and programmers found it difficult to use. Later versions of JavaScript resolved this difficulty with exceptions handling features like try..catch handlers, which…
JavaScript Document Object
JavaScript Document Object In this JavaScript tutorial, you will learn about document object – part of JavaScript window object, properties and windows of document object, alinkColor, anchors, applets, bgColor, cookie, domain, embeds and fgColor. The Document object is part of the Window object. The document object is used to access all elements in a page. The document object provides access to the elements in an HTML page from within the script. General syntax of document object: window.document There are many properties and methods available for the document object. Some of these are mentioned and briefly explained below: Properties of document Object:…
JavaScript Array Operations
JavaScript Array Operations In this JavaScript tutorial, you will learn about different operations with array in JavaScript, how to use the for…in statement, Combining Operations between arrays and within elements of an array, joining two or more arrays and joining elements of an arrays along with syntax and example scripts.for…in statement: The for…in statement is used for looping through the elements of the array. The general structure of the for..in statement in JavaScript is as follows: for (variablename in arrayname) { ………… ………… //Block of Code to be executed } <html> <body> <script type="text/javascript"> var A …
JavaScript Iterative Structures – Part II
In this JavaScript tutorial, you will learn about JavaScript Iterative Structures, while loop and do..while loop explained along with syntax and examples.
JavaScript Iterative Structures – Part I
JavaScript Iterative Structures – Part I In this JavaScript tutorial, you will learn about JavaScript Iterative Structures, for loop, for..in statement, break and continue explained along with syntax and examples. Iterative Structures are used to execute a certain piece of code a specified number of times or until the condition mentioned remains true. The Iterative structures are also termed “looping” in programming terminology. Iterative Structure is an important part of programming terminology. When a programmer wants to repeat the same code a number of times, he or she does not have to rewrite the code again and again, resulting in…
This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish.AcceptReject Read More Privacy & Cookies Policy