document object
JavaScript topics covered:
  1. images
  2. forms
  3. links

Document Reference


document object

In JavaScript you are given the default object called Window. Within the Window, there is the HTML Document. On the HTLM document we have our HTML elements, like images, forms, links etc. You can refer to an HTML tag using its element number or its NAME attribute. So, if I have a browser window, and in the window is a document, and on the document is an image I could access the source property of that image by:

  document.images[0].src
  document.imageName.src
  document[imageName].src
  

  1. Some other properties that describe an image are (src, name, width, height, alt, border, align).

    <img name=myImage src="character3.gif" alt="Just a growing!">

    Just a growing!

    document.images[0].height  height
    document.images[0].width  width
    document.images[0].src  src

    click here to see the demo.

  2. Change the background color

    document.bgColor="red";

    Want to change the back ground color? blue    red    white   


  3. Last modified property

    document.write("Last updated " + document.lastModified);

  4. Change the link color:

    document.linkColor="color"; link color
    document.alinkColor="color";active link color
    document.vlinkColor="color";visited link color

    links orange    visited links green    active links red

  5. The title Property

    document.title
    name of document

    I use the title tag to build the top part of each section of this web site.
    click here to see the demo.


  6. The URL property

    document.URL
    document address
  7. Change the name of a button

    You can access the button 'value' several ways:

    document.forms[0].elements[0].value="new value"
    document.formName.elements[0].value="new value"
    document.forms[0].buttonName.value="new value"
    document.formName.buttonName.value="new value"

    new value    my button