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… Read More

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… Read More

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,… Read More

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… Read More

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… Read More

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… Read More

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.… Read More

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>      … Read More

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.… Read More

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… Read More

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… Read More

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)… Read More

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)… Read More

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… Read More

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… Read More

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… Read More

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 }… Read More

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… Read More

JavaScript Array Object Methods – Part II

JavaScript Array Object Methods – Part II In this JavaScript tutorial, you will learn about on array object methods – slice(), splice() toString(), shift() and unshift() methods along with general syntax and examples. slice(): By using the methods of the array object the programmer is able to retrieve the first and the last elements in an array object. Suppose a programmer wishes to retrieve selected elements from an existing array. This can be performed by using the slice() method of the array object. The slice method creates a new array… Read More

JavaScript Array Object Methods – Part I

JavaScript Array Object Methods – Part I In this JavaScript tutorial, you will learn about Array Object Methods – concat(), join(), pop(), push() and reverse() methods along with general syntax and examples. concat() The concat() method is used to join two or more Array objects together to produce a new one. In the concat() method, the original Array objects are unaffected by this method and only a copy of the new concatenated array is returned. General syntax of the concat() method of the Array object of JavaScript: arrayObject.concat(arrayname1,arrayname2,……,arraynamen) An example to… Read More

JavaScript Location Object

JavaScript Location Object In this JavaScript tutorial, you will learn about JavaScript Location Object – assign(), reload(), replace(), JavaScript Window Object Methods viz alert(), blur(), setInterval() and clearInterval().Methods of Location Object assign(): The assign method of location object is used for loading a new document. General syntax of assign method of location Object: location.assign(URL) for example   <html>    <head>       <script type="text/javascript">          function test()          {           window.location.assign("http://www.exforsys.com")          }       </script>    </head>      <body>        <input type="button" value="Click Here For Loading New Document" onclick="test()" />   … Read More

JavaScript Window Object Open Method

JavaScript Window Object Open Method In this JavaScript tutorial, you will learn about JavaScript Window Object Open Method, features of window object open method – channelmode, directories, dependent, fullscreen, screenX, screenY, height, left, location, menubar, resizable, alwaysLowered, alwaysRaised channelmode: Syntax: channelmode=yes|no|1|0 The channelmode is used to denote whether the user wants to display the window in theater mode or not. The default setting of this feature is NO. The user can set channelmode value to YES which would then display the window in theater mode. This is a very important… Read More

JavaScript Window Object Open Method Part 2

JavaScript Window Object Open Method Part 2 In this JavaScript tutorial, you will learn about JavaScript Window Object Open Method, features of window object open method – scrollbars, status, titlebar, toolbar, top, width, innerHeight, innerWidth, outerHeight, outerWidth and hotkeys scrollbars: Syntax: scrollbars=yes|no|1|0 The scrollbar feature denotes whether or not the scroll bars should be displayed. The default value of the scrollbars feature is YES, displaying the scroll bars. If the value of the scrollbars feature is set to NO by the user, then the scroll bars are not displayed. status:… Read More

JavaScript DOM Window Object

JavaScript DOM Window Object In this JavaScript tutorial, you will learn about closed property and name property, defaultStatus, status, self property of JavaScript Window object closed Property of Window Object: The closed property of a Window object returns a Boolean variable denoting whether window has been closed or not. The closed property tells you whether or not a window opened using window.open(). Once a window is opened in JavaScript, its closed property is immediately initialized, with a value of false. When the newly opened window is closed, then the closed… Read More

JavaScript Browser Objects Part 2

JavaScript Browser Objects Part 2 In this JavaScript tutorial, you will learn about Browser Objects viz button object properties of button object, form, name, value, Methods of button object, checkbox object, properties of checkbox object – checked, defaultChecked, form, name, type, value, Methods of checkbox object – blur(), click() and focus(). button object: The button object is a browser object in JavaScript that is used to access a form button other than submit or reset. The button object is a property of the form object. General syntax of button object… Read More

JavaScript Location Object Properties

JavaScript Location Object Properties In this JavaScript Tutorial you will learn about Properties of Location Object – hash, host, hostname, href, pathname, port, protocol and search property The Location object contains information about the current URL. This representation is a string that denotes the different portions of the URL as below: <protocol>//<host>[:<port>]/<pathname>[<hash>][<search>] The location object has a number of properties and methods in it. The usage, syntax and explanation with examples of each of the properties and methods of the Location object are explained in this section and the following… Read More

JavaScript Browser Objects

JavaScript Browser Objects In this JavaScript tutorial, you will learn about browser objects in JavaScript, categories of browser-based objects, additional browser objects, anchor object, link object, properties of link object and methods of link object. JavaScript supports a number of browser-based objects. When a webpage loads by a browser that supports JavaScript, the browser creates a variety of JavaScript objects. This makes it possible to access the web page and handle elements, like HTML. There are a vast number of browser objects for JavaScript. This section highlights some of the… Read More

JavaScript Applet Objects

JavaScript Applet Objects In this JavaScript tutorial, you will learn about applet object, properties and methods of applet object, Methods of applet object, area object, Properties of area object viz. hash, host, hostname, href, pathname, port, protocol, search and target. applet object: The applet object is used in JavaScript to access a Java applet. User can make use of the applets array to access all the applets contained in a document. The applets array property gives access to all the applets associated with the document. The applet object is a browser… Read More

JavaScript Document Object Properties

JavaScript Document Object Properties In this JavaScript tutorial, you will learn about Document Object Properties viz. formName, forms, images, lastModified, layers, linkColor, links, plugins, referrer, title, URL and vlinkColor. formName: Using the formName property, any form in the document can be referred and the formName is assigned as <FORM NAME = "formID">. General syntax for using the formName property is as follows: document."formname" forms: When a programmer wants to refer all the Form objects in a current document, then he or she can make use of the forms property. The… Read More

JavaScript Event Object Properties and Methods

JavaScript Event Object Properties and Methods In this JavaScript tutorial, you will learn about event object properties and methods like keycode, layer, offset, modifiers, page, reason, returnValue, screen, srcElement, target, srcFilter and type. keycode: The keycode property of event object is used to indicate the keycode associated with the key press of the event. The returned value is a Unicode keycode. If a user wants to convert the value as string, then the predefined function fromCharCode() must be used for conversion. The property keycode is supported only by Internet Explorer… Read More

JavaScript Boolean Object

JavaScript Boolean Object In this JavaScript tutorial you will learn about JavaScript boolean object, how to pass value to the boolean object, properties and methods used with boolean object. Usage of the Boolean Object: The Boolean object is a wrapper for the Boolean data type. The Boolean object is used to convert a non-Boolean value to a Boolean value. If a programmer wants to convert a non-Boolean value to a Boolean value, he can use Boolean as a function to perform this task, instead of using a Boolean object to… Read More

JavaScript Arrays

JavaScript Arrays In this JavaScript tutorial, you will learn about JavaScript Array, different ways of defining an array in JavaScript viz. traditional way, shorter form, literal array, accessing the elements in an array and editing the values or elements in an array. The array concept is used to store a set of values in a single variable name. This is a very important concept in any programming language. In this section, how to define and handle arrays in JavaScript is examined. In order to work with the concept of arrays… Read More

JavaScript Two Dimensional Arrays

JavaScript Two Dimensional Arrays In this JavaScript tutorial you will learn about two dimensional arrays – how to define and access two dimensional array in JavaScript. Two Dimensional Arrays in JavaScript: Two Dimensional Arrays are storing elements in a structure similar to that of a table. Defining Two Dimensional Arrays in JavaScript: One of the vital points to note is JavaScript does not support multi-dimensional arrays and thereby does not support Two Dimensional Array. In order to create a Two Dimensional Array in JavaScript, the programmer must use the concept of creating… Read More

JavaScript Array Object

JavaScript Array Object In this JavaScript tutorial, you will learn about JavaScript Array Object, its properties and methods. Usage of the Array Object: The Array object is used to store a set of values in a single variable name. There are many operations involved with Array object: Defining Array object Adding Values to Array Accessing Array Editing or Modifying the Values of an Array These topics have been addressed in previous sections on Arrays in JavaScript. In this section, the properties and methods of Array Object in JavaScript will be… Read More

JavaScript Functions

JavaScript Functions In this JavaScript tutorial, you will learn about JavaScript functions and how to create them. What is a function? Function is a block of code that can be reused as and when needed at various places. The function executes whenever it is called. JavaScript Functions: How does a programmer define, create and handle functions in JavaScript? In JavaScript, the programmer must learn the following broad classifications to fully understand the concept of functions. Idea of JavaScript functions Creating a function in JavaScript Passing values to function Returning values… Read More

Passing values to JavaScript Function

Passing values to JavaScript Function In this JavaScript Tutorial you will learn about how to pass values to and also how to return values from a JavaScript function. Passing Values to function: Values can be passed to a function as parameters. The general syntax for passing values to a function in JavaScript is: function name_of_function(argument1,argument2,…argumentn) { ………………………………………… //Block of Code ………………………………………… } In the above argument1, argument2,…argumentn represents the values passed to the function. For Example: Suppose a programmer wants to create a function with name exforsys, which takes two… Read More

Working with JavaScript DOM Objects

Working with JavaScript DOM Objects In this JavaScript tutorial, you will learn about DOM object – window, properties of window object, methods of window object, screen, properties of screen object, navigator, properties of navigator object, methods of navigator object, history, property of history object, methods of history object, location, properties of location object and methods of location object. DOM stands for Document Object Model. Document Object Model or DOM is a set of objects that allow programmers scripts to integrate with the browser and work with documents, windows, forms, and… Read More

JavaScript Frame object

JavaScript Frame Object In this JavaScript tutorial, you will learn about frame object its properties and methods in detail with example. frame object, properties of frame object, frames, self, name, length, parent, methods of frame object, blur(), focus(), setInterval(), clearInterval(), setTimeout(expression, milliseconds), clearTimeout() and events associated with frame object. Frame Object: The frame object is a browser object of JavaScript used for accessing HTML frames. The user can use frames array to access all frames within a window. Using the indexing concept, users can access the frames array. NOTE: The… Read More

JavaScript Events Handling

JavaScript Events Handling In this JavaScript tutorial, you will learn about handling events in JavaScript, what is event handling in JavaScript? events in JavaScript, events associated with mouse – onmousemove, onclick, ondblclick, onmouseout, onmouseover, events associated with keyboard – onkeydown, onkeyup, onkeypress. onerror, onfocus, onblur, onsubmit, onload and onunload. What is Event Handling in JavaScript? This is a very vital concept of JavaScript because without events there would be no code. Event handling is the execution of code for the user’s reaction. In other words, when a user performs some… Read More

JavaScript Object Oriented Features

JavaScript Object Oriented Features In this JavaScript tutorial you will learn about JavaScript Object Oriented Features, object type, object instantiation, using object properties, using object methods and achieving object instantiation. Object-oriented capabilities make any language or application powerful. This section outlines the object oriented features supported by JavaScript and how to use them in programming process. JavaScript is not a complete programming language but, rather, it is a scripting language. There are some object-oriented features that are not supported by JavaScript. JavaScript does not support the features of inheritance, information… Read More

JavaScript Event Object

JavaScript Event Object In this JavaScript tutorial you will learn about JavaScript event object, properties of event object, altKey, ctrlKey and shiftKey, button, integer value action representation, cancelBubble, clientX and clientY, fromElement and toElement, height and width. event Object: The event object is a browser object used to get information about a particular event specified. Using event object, users can access information about event happenings. The difference between event object and Event object is such that the latter gives constants that can be used to identify events, while the former… Read More

JavaScript Form Object

JavaScript Form Object In this JavaScript Tutorial you will learn about JavaScript form object, properties of form object, action – elements[], encoding, length, method, name, target, button, checkbox, FileUpload, hidden, password, radio, reset, select, submit, text, textarea and methods of form object. Form Object: form object is a Browser object of JavaScript used to access an HTML form. If a user wants to access all forms within a document then he can use the forms array. The form object is actually a property of document object that is uniquely created… Read More

JavaScript FileUpload Object

JavaScript FileUpload object In this JavaScript tutorial, you will learn about FileUpload object, FileUpload properties, accessKey, disabled, form, name, type, value, FileUpload methods – blur(), focus(), select(), handleEvent(), click() and event handlers – onblur, onchange and onfocus.   FileUpload object: FileUpload represents an element that allows a user to specify a file to be uploaded or submitted along with the form. The FileUpload object is a Browser object and is used to access the above FileUpload element of a form. Thus, the FileUpload object allows the user to give any… Read More

JavaScript Alert Box

JavaScript Alert Box In this JavaScript tutorial, you will learn about JavaScript alert box along with code for placing the alert box when page is loaded. There are three types of popup boxes that can be created using JavaScript. Depending on the needs of user, the programmer can create any of these types of popup boxes using JavaScript.  Three kinds of popup boxes created using JavaScript are: Alert Box Confirm Box Prompt Box Let us now learn how to create each of these popup boxes using JavaScript. Alert Box: This… Read More

JavaScript Confirm Box

JavaScript Confirm Box In the previous section of this tutorial JavaScript Alert Box, we discussed about alert boxes. In this section, you will learn about JavaScript confirm box and prompt box. Confirm Box: The confirm box is a box that pops up with both an OK and a Cancel button. The confirm box is used to verify acceptance from the user. If the user accepts, then the user presses the OK button and the confirm box returns with a true value. If the user rejects with the Cancel button, then… Read More

JavaScript Features

JavaScript Features In this JavaScript tutorial, you will learn about features of JavaScript, JavaScript as a programming tool, dynamic effects, browser detection, DOM control and other popular JavaScript features. A Great Programming Tool for HTML: Professional Web designers are undoubtedly adept in using HTML and proficient in website design but not necessarily skillful in computer programming. JavaScript is a programming tool for such a situation. JavaScript is a powerful scripting language that helps HTML designers to effectively and interactively design websites and web pages in a very simple and efficient way.… Read More

How to use JavaScript in HTML page

How to use JavaScript in HTML page In this JavaScript tutorial you will learn how to use JavaScript in HTML page, how to write output to a page, different places where JavaScript can be paced in HTML, JavaScript in external file and how to place and execute JavaScript in external file. How to Insert JavaScript into a HTML page: You can insert JavaScript into an HTML page by using <script> tag. JavaScript is placed between tags starting with <script type = text/javascript> and ending with </script>. General syntax of JavaScript… Read More

JavaScript Variables

JavaScript Variables In this JavaScript tutorial, you will learn about JavaScript variables, rules for variable names in JavaScript, declaration of variable in JavaScript, variables usage, JavaScript in external file, how to place the JavaScript in external file and how to execute this JavaScript placed in external file. Just like any programming language, variables in JavaScript are also used to store values. The value of the variable can be edited as required by the programmer. Rules for Variable Names in JavaScript: Some of the rules for forming variable names are as… Read More

JavaScript Introduction

JavaScript Introduction In this JavaScript tutorial, you will learn about introduction to JavaScript, why JavaScript, differences between Java and JavaScript and advantages of JavaScript. What is JavaScript? JavaScript was first developed by Netscape as an open scripting language to create interactive web pages. Script is nothing but a small program which is generally very easy to learn and use. JavaScript as an open language implies that it can be used by anyone; no license is required to use JavaScript. Microsoft created Jscript for its Internet Explorer similar to Netscape JavaScript.… Read More