Logo

Navigation
  • Home
  • Services
    • ERP Solutions
    • Implementation Solutions
    • Support and Maintenance Solutions
    • Custom Solutions
    • Upgrade Solutions
    • Training and Mentoring
    • Web Solutions
    • Production Support
    • Architecture Designing
    • Independent Validation and Testing Services
    • Infrastructure Management
  • Expertise
    • Microsoft Development Expertise
    • Mobile Development
    • SQL Server Database and BI
    • SAP BI, SAP Hana, SAP BO
    • Oracle and BI
    • Oracle RAC
  • Technical Training
    • Learn Data Management
      • Business Intelligence
      • Data Mining
      • Data Modeling
      • Data Warehousing
      • Disaster Recovery
    • Learn Concepts
      • Application Development
      • Client Server
      • Cloud Computing Tutorials
      • Cluster Computing
      • CRM Tutorial
      • EDI Tutorials
      • ERP Tutorials
      • NLP
      • OOPS
      • Concepts
      • SOA Tutorial
      • Supply Chain
      • Technology Trends
      • UML
      • Virtualization
      • Web 2.0
    • Learn Java
      • JavaScript Tutorial
      • JSP Tutorials
      • J2EE
    • Learn Microsoft
      • MSAS
      • ASP.NET
      • ASP.NET 2.0
      • C Sharp
      • MS Project Training
      • Silverlight
      • SQL Server 2005
      • VB.NET 2005
    • Learn Networking
      • Networking
      • Wireless
    • Learn Oracle
      • Oracle 10g
      • PL/SQL
      • Oracle 11g Tutorials
      • Oracle 9i
      • Oracle Apps
    • Learn Programming
      • Ajax Tutorial
      • C Language
      • C++ Tutorials
      • CSS Tutorial
      • CSS3 Tutorial
      • JavaScript Tutorial
      • jQuery Tutorial
      • MainFrame
      • PHP Tutorial
      • VBScript Tutorial
      • XML Tutorial
    • Learn Software Testing
      • Software Testing Types
      • SQA
      • Testing
  • Career Training
    • Career Improvement
      • Career Articles
      • Certification Articles
      • Conflict Management
      • Core Skills
      • Decision Making
      • Entrepreneurship
      • Goal Setting
      • Life Skills
      • Performance Development
      • Personal Excellence
      • Personality Development
      • Problem Solving
      • Relationship Management
      • Self Confidence
      • Self Supervision
      • Social Networking
      • Strategic Planning
      • Time Management
    • Education Help
      • Career Tracks
      • Essay Writing
      • Internship Tips
      • Online Education
      • Scholarships
      • Student Loans
    • Managerial Skills
      • Business Communication
      • Business Networking
      • Facilitator Skills
      • Managing Change
      • Marketing Management
      • Meeting Management
      • Process Management
      • Project Management
      • Project Management Life Cycle
      • Project Management Process
      • Project Risk Management
      • Relationship Management
      • Task Management
      • Team Building
      • Virtual Team Management
    • Essential Life Skills
      • Anger Management
      • Anxiety Management
      • Attitude Development
      • Coaching and Mentoring
      • Emotional Intelligence
      • Stress Management
      • Positive Thinking
    • Communication Skills
      • Conversation Skills
      • Cross Culture Competence
      • English Vocabulary
      • Listening Skills
      • Public Speaking Skills
      • Questioning Skills
    • Soft Skills
      • Assertive Skills
      • Influence Skills
      • Leadership Skills
      • Memory Skills
      • People Skills
      • Presentation Skills
    • Finding a Job
      • Etiquette Tips
      • Group Discussions
      • HR Interviews
      • Interview Notes
      • Job Search Tips
      • Resume Tips
      • Sample Resumes
 

JavaScript Document Object

By Exforsys | on July 29, 2007 |
JavaScript Tutorial

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:

* alinkColor
* anchors
* applets
* bgColor
* cookie
* domain
* embeds
* fgColor
* formName
* forms
* images
* lastModified
* layers
* linkColor
* links
* plugins
* referrer
* title
* URL
* vlinkColor

Methods of document Object:

* captureEvents
* close
* getElementById
* getElementsByName
* getElementsByTagName
* getSelection
* handleEvent
* open
* releaseEvents
* routeEvent
* write
* writeln

In the next few sections, these properties and methods of the document object with examples will be examined.

This section discusses the properties alinkColor, anchors applets, bgColor, cookie and domain in detail with examples given for each.

Properties of document Object:

alinkColor:

This property can be used if the programmer wishes to define the color of an active link.

The general syntax for using the alinkColor property of document object is as follows:

document.alinkColor = "Information of color"

Here the "Information of color" is a string that is given either as a hexadecimal representation or, directly, as a literal description denoting the color of the active link needed.

anchors:

If a document has a number of anchor objects and a programmer wants to refer to the document, then the anchors property can be used. The anchors property is an array that references all anchor objects associated with the current document.

The general syntax for using the anchor property is as follows:

document.anchors["anchorID"]

Here "anchorID" is the identification of the anchor that the programmer wants to refer to.

applets:

If a document has a number of Applet objects and if the programmer wants to refer to the document, then the applets property can be used. The applets property is an array that references all Applets objects associated with the current document.

The general syntax for using the applets property is as follows:

document.applets["appletID"]

In this example, "appletID" is the identification of the applet that the programmer wants to refer to.

bgColor:

This property can be used if the programmer wishes to define the background color of the document.

The general syntax for using the bgColor property of a document object is as follows:

document.bgColor = "Information of color"

Here, the "Information of color" is a string that is given either as a hexadecimal representation, or directly, as a literal description denoting the background color of the document needed.

cookie:

The cookie property is used to set or return all cookies associated with the current document.

The general syntax for using the cookie property of a document object is as follows:

document.cookie

An example to understand its usage in brief:


<html>
   <
body>
      <
script type="text/javascript">
         document.write("The Associated Cookie with this
         document is: " + document.cookie)

      </script>
   </
body>
</
html>

Output of the above script is

The Associated Cookie with this document is: ABCWEYUWYEUWYUE

The cookie associated with the current document displays.

domain:

The domain property is used to set or return the domain name of the server where the current document originated.

The general syntax for using the domain property of document object is as follows:

document.domain

An example to understand its usage in brief:


<html>
   <
body>
      <
script type="text/javascript">
         document.write("The Document’s Domain Name is: " +
         document.domain)

      </script>
   </
body>
</
html>

The output of the above program is

The Document’s Domain Name is: www.exforsys.com

The current document’s domain name displays.

embeds:

When a programmer wants to refer to all the embedded objects in a current document, then he or she can make use of the embeds property.

The general syntax for using the embeds property is as follows:

document.embeds["Id_of_embed_obj"]

fgColor:

There exists a property to defining the background color of a document, and it is also possible to define the foreground or the text color of the document. The fgColor property can be used if the programmer wishes to define the foreground or text color of the document.

The general syntax for using the fgColor property of document object is as follows:

document.fgColor = "Information of color"

Here, the "Information of color" is a string that is given either as a hexadecimal representation, or directly, as a literal description denoting the foreground color of the document needed.

« « JavaScript Array Operations
Using NLP for Leadership Skills » »

Author Description

Avatar

Editorial Team at Exforsys is a team of IT Consulting and Training team led by Chandra Vennapoosa.

Free Training

RSSSubscribe 394 Followers
  • Popular
  • Recent
  • JavaScript String Object

    August 12, 2007 - 0 Comment
  • JavaScript Window Object Open Method

    July 4, 2007 - 0 Comment
  • JavaScript Event Handler

    August 2, 2007 - 0 Comment
  • JavaScript Browser Objects Part 2

    June 13, 2007 - 0 Comment
  • JavaScript DOM Window Object

    June 21, 2007 - 0 Comment
  • JavaScript Date Object

    August 12, 2007 - 0 Comment
  • JavaScript Window Object Open Method Part 2

    July 4, 2007 - 0 Comment
  • JavaScript Exception Handling – Part I

    August 2, 2007 - 0 Comment
  • JavaScript Windows Object Properties Part I

    August 8, 2007 - 0 Comment
  • JavaScript Math Object

    August 9, 2007 - 0 Comment
  • JavaScript Objects

    August 12, 2007 - 0 Comment
  • JavaScript String Object

    August 12, 2007 - 0 Comment
  • JavaScript Date Object

    August 12, 2007 - 0 Comment
  • JavaScript Math Object

    August 9, 2007 - 0 Comment
  • JavaScript Windows Object Properties Part II

    August 9, 2007 - 0 Comment
  • JavaScript Windows Object Properties Part I

    August 8, 2007 - 0 Comment
  • JavaScript Window Object Timeout Methods

    August 8, 2007 - 0 Comment
  • JavaScript Document Object Methods Part II

    August 7, 2007 - 0 Comment
  • JavaScript Document Object Methods Part I

    August 5, 2007 - 0 Comment
  • JavaScript History Object Properties and Methods

    August 5, 2007 - 0 Comment

Exforsys e-Newsletter

ebook
 

Related Articles

  • JavaScript Objects
  • JavaScript String Object
  • JavaScript Date Object
  • JavaScript Math Object
  • JavaScript Windows Object Properties Part II

Latest Articles

  • Project Management Techniques
  • Product Development Best Practices
  • Importance of Quality Data Management
  • How to Maximize Quality Assurance
  • Utilizing Effective Quality Assurance Strategies
  • Sitemap
  • Privacy Policy
  • DMCA
  • Trademark Information
  • Contact Us
© 2023. All Rights Reserved.IT Training and Consulting
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

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.
Non-necessary
Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.
SAVE & ACCEPT