Document Object

By: aathishankaran Emailed: 1649 times Printed: 2130 times    

Latest comments
By: rohit kumar - how this program is work
By: Kirti - Hi..thx for the hadoop in
By: Spijker - I have altered the code a
By: ali mohammed - why we use the java in ne
By: ali mohammed - why we use the java in ne
By: mizhelle - when I exported the data
By: raul - no output as well, i'm ge
By: Rajesh - thanx very much...
By: Suindu De - Suppose we are executing

The window object is the highest-level object for built-in JavaScript objects; in this role, it serves as a container, but it does not have any content that is associated with it, per se. It leaves the content of a Web document up to the document object. The document object serves as the JavaScript equivalent of an HTML document. In this role, the document object is a container for all HTML related objects that are associated with both the <HEAD> and <BODY> tags. The document object gets its title property from the <TITLE> tag (located within the <HEAD> section) and several color-related properties from the <BODY> section, which is shown here: 

Syntax 

<BODY [BACKGROUND="backgroundImage"][BGCOLOR="backgroundColor"]

[TEXT="foregroundColor"] [LINK="unfollowedLinkColor"]

[ALINK="activatedLinkColor"] [VLINK="followedLinkColor"]

[onLoad="methodName"] [onUnload="methodName"]>

</BODY>  

Although onLoad and onUnload events are associated with the <BODY>tag, they are events of the window object, not the document object. The document object is critical as you' work with JavaScript and HTML because all the action happens on a Web page within a document. Because of this scope, you need to refer to the document object when you are accessing an object within it. For example, if you want to access a form object named invoiceForm, you must preface your reference with document: 

document.invoiceForm.submit() 

If you do not, JavaScript is unable to locate the object within the page. 

Changing Document Attribute Colors 

Color settings for documents are usually set by a user in his browser configuration, but JavaScript gives you the ability to change these color settings programmatically. The document object has five properties that reflect the colors of various attributes within the document alinkColor, bgColor,  fgColor, linkColor, and vlinkColor 

Property Description HTML Tag

alinkColor

Color of an activated link(after mouse down, before mouse up)

ALINK=

bgColor

Background color of document

BGCOLOR=

fgColor

Foreground color of document

TEXT=

IinkColor

Color of unvisited links

UNK=

vlinkColor

Color of visited links

VUNK=

             These properties are expressed either as string literals or as hexadecimal RGB triplet values. For example, if you wanted to assign a background color of chartreuse to a document, you could use the string literal chartreuse: 

document.bgColor = chartreuse 

You could also use the equivalent hexadecimal RGB triplet value: 

document.bgColor = "7fffOO" 

Link Object 

HTML links are the core elements of any Web document, enabling you to jump to another Web page with the click of a mouse. The location of the document is immaterial; it could be on the same Web server or thousands of miles away. All that matters is that the URL is valid. The link object is the JavaScript equivalent of the hypertext link, which is defined in HTML syntax as 

<A HREF=locationOrURL [NAME="objectName"] [TARGET="windowName"]

[onClick="'methodName"][onMouseOver="methoQName"]> linkText </A> 

The link object has several properties that are the same as the parameters for the location object. These include hash, host, hostname, href, pathname, port, protocol, and search. 

Anchor Object 

You most often use a link object to jump to another Web page or another location within the current document. Within the current document, the link locates a specific place in the text called an anchor, which is defined in HTML syntax as 

<A [HREF=locationOrURL] NAME="objectName" [TARGET="windowName"]>

anchorText </ A> 

To be politically correct, you could say that the anchor object is "JavaScript challenged" be-cause you can do little in JavaScript with anchors. By itself, an anchor object has no properties, methods, or events. The only way you can really use them in JavaScript is through the anchors array of the document object. You can use the anchors array to determine the number of anchors in a document and iterate through them as desired.

Image Object 

The image object is new to Netscape Navigator 3.0. If you spend any time at all on the Web, you quickly realize how important graphics are to the Web. You can hardly go to a page without seeing several graphics scattered throughout. New to Netscape Navigator 3.0, the image object represents an HTML image, which is defined in the following format: 

<IMG [NAME="objectName"]' SRC="Location" [LOWSRC="Location"][HEIGHT="Pixels"|"Value"%] [WIDTH="Pixels"|"Value"%] [HSPACE="Pixels"]

[VSPACE="Pixels"] [BORDER="Pixels"] [ALIGN="left"|"right"| "top"|"absmiddle"|"absbottom"|"texttop"|"middle"|"baseline"|"bottom"][ISMAP] [USEMAP="Location#MapName"] [onAbort="methodName"][onError="methodName"] [onLoad="methodName"]>


JSP Home | All JSP Tutorials | Latest JSP Tutorials

Sponsored Links

If this tutorial doesn't answer your question, or you have a specific question, just ask an expert here. Post your question to get a direct answer.



Bookmark and Share

Comments(0)


Be the first one to add a comment

Your name (required):


Your email(required, will not be shown to the public):


Your sites URL (optional):


Your comments:



More Tutorials by aathishankaran
Web Security Issues
The Web User's Perspective
Server-side plug-Ins
The best way to avoid security vulnerabilities with new server
JavaScript Security
Window Object
Working with Status Bar Messages
Retrieving a Portion of a String
Referencing Windows
Math Object
Frame Object
Document Object
Closing Windows
Built-in Object in Javascript
Textarea Object

More Tutorials in JSP
LifecycleException: service.getName(): "Catalina"; Protocol handler start failed: `java.net.BindException: Permission denied <null>:80
JSP Alert Example
JSP CheckBox Example
Uploading an Image to a Database using JSP
Uploading a file to a server using JSP
A JSP page that gets properties from a bean
The page Directive in JSP
The taglib, tag, include, attribute and the variable Directive in JSP
Declarations in JSP
Scriptlets and Expressions in JSP
Tag Libraries in JSP
The Request Object in JSP
The Response Object in JSP
The Out Object in JSP
The Session Object in JSP

More Latest News
Most Viewed Articles (in JSP )
JSP Example to connect to MS SQL database and retrieve records
The Request Object in JSP
What are the different scopes in JSP?
JSP Alert Example
JSP CheckBox Example
Disabling Scriptlets in JSP using web.xml
Sending Email using JSP
Embedding java codes in jsp sciptlets
Combining Scriptlets with HTML
Automatically Including Preludes and Codas in JSP
Calling JSP from a batch file
Deploying an Individual JSP on Tomcat
Using a DataSource from WebLogic in a JSP
Embedding a QuickTime movie in a JSP
Tags using in jsp
Most Emailed Articles (in JSP)
Steps to get a Free SSL certificate for your Tomcat
What is JSP?
Retrieving a Portion of a String
Tag libraries
Tags using in jsp
Closing Windows
Getting HTTP Request Headers in a JSP
LifecycleException: service.getName(): "Catalina"; Protocol handler start failed: `java.net.BindException: Permission denied <null>:80
Click to Activate and Use this control
Radio Object
Math Object
What is JSP?
Cookies using JSP or Java Bean
Built-in Object in Javascript
Frame Object