Javascript OOPS

 Frame Object


As you learn in this book, frames are especially important objects to use to enhance the presentation of your web application. The frame object represents a frame within a frameset. In a multi-frame presentation, your window object is the page that contains the <FRAMESET> definition, whereas the other pages are considered frames in that context.


Location Object


The Web is all about content representation. Every window object is designed to display content to the user, but that content must come from somewhere. The origin of the page is thus contained in the location object. The location object is used to store all URL information for a given window.Although users see URL information in the Location box on-screen , you can work with that same information with the location object.


If you want to retrieve the protocol portion of the current URL and evaluate it , you use the following:

function evalProtocol()

{

curProtocol = window.location.protocol

if(curProtocol=="http:")

{

alert("The document comes from your hand drive.")

}

else

{

alert("This document comes from somewhere else.")

}

}

}


History Object


A long-time features in browser is the capability to track where you have surfed within a given session. This features has come to be known as a history list, and it's available in both the Navigator and internet Explorer's Go menus. The history object is the javascript equivalent to this list. You can work with it as a user might, moving forward or backward in a list to navigate where a user has been.


Suppose you wanted to go back two pages in your history list when the user clicked a button. The event handler follows:


function goBackTwoPages()

{

window.history.go(-2)

}


Document Object


Although the window object is the top-level object in the hierarchy , the document object is arguably the most important. The document object is responsible for all the actual content displayed on a given page. You can work with the document object to display dynamic HTML pages. Also contained within the document are all the typical user interface (UI) elements of a web application.


A common use of the document object is generating HTML pages through Javascript. You can do this with the write() or written() methods. For example , the following code displays the HTML text specified as the method parameter:


<html>

<head>

<script language="javascript">

document.write("<h1>Text created by javascript</h1>");

</script>

</head>

</html>


Form Object


Forms gives life to static pages by providing an interface users  can interact with through controls. You can only place a button, text, or other UI objects within the confines of a form. The form object is your means of inter-acting with this HTML element in your scripts.


Button Objects(Button, submit, and Reset)


Unless you jumped into web development from a character-based environment, you are undoubtedly familiar with push buttons. Javascript has three button objects: button, submit, and reset. Each of these are the object representation of an HTML tag. The button object is a generic button that you need to add code to for it to be useful. The submit button is a specialized version of a button whose default action is to submit the form of which it is a part. Similarly , the reset button is hard coded to reset the values of all controls within a form. Yes, you could use a button object to serve the same role as the submit object (by calling the form's submit() method).


select Object


Another common control in windowed environments is a drop-down list or selection list box , both of which allow a user to select from a predefined list of values. The difference is that the user can select only one value from a drop-down list, whereas he can select multiple choices from a selection list. The select object encapsulates the behavior of both of these UI elements. In other words, it can appear as a drop-down list(default) or a seletion list(if its multiple property is set to true).


Checkbox Object


Another industry-wide standard UI control is the checkbox. This element allows the user to specify a yes/no or true/false value by clicking the checkbox control.


Radio Object


Radio buttons are a set of mutually exclusive controls, such that if one radio button is selected, all other buttons in the set become unselected. The radio object provides this element in an HTML form. You define a set of radio buttons by giving them the same name property.


Text Object


A principle element for any data entry application is a field in which the user can input data. The text object serves as this data-capturing device as the objectified representation of the text input HTML tag.



Textarea Object


Related to the text object is the textarea object , which allows you to enter multiple lines of text as opposed to a single line.


Password Object


The only difference between the text and password is that all the characters entered into the password object are displayed as asterisks.


Hidden Object


Another field object , the hidden object is like a text object with a visible property set to false.

It is used to store values to pass on to a server process . The hidden object comes from the pre-javascript days of HTML in which there were no such things as variables, arrays, or objects to store values.


Link Object


The link object lets you work with links in Javascript code, the link still remains the very heart of web technology. Because a link is simply referencing another HTML page or other destination, it is very similar to the location object which contains the same information for the current HTML page.


Anchor Object


The anchor object is a piece of text or an image in the HTML page that can be the target of a hypertext link. In practical terms , you use the anchor object very little with Javascript , making it perhaps the least important of all built-in objects.


Image Object


The image object is an encapsulation of an HTML image. Perhaps the most effective use of this object type is to cache images you want to display. You can construct an image object in your code and download the image data from the server before it is needed for display by the browser.


Navigator Object


The navigator object is an object representing the browser software in use. Using this object, you can retrieve information about the name and version of the browser in use.


String Object


The String object represents a value you assign to a variable of an object property. Javascript treats both assigned variables and string literals as string objects.


Array Object


An array is an ordered set of data elements, and every index number is an array contains a value.


Math Object


The math object is used for standard mathematical calculations. Rather than using generic math functions in Javascript , these functions are implemented as methods of the math object. Suppose you wanted to evaluate two numbers that the user entered.


No comments:

Post a Comment