Javascript
  1. Javascript intro
  2. Javascript basics
  3. Javascript variables
  4. Javascript functions
  5. Javascript popup boxes
  6. Javascript conditions
  7. Javascript loops
  8. Javascript arrays
  9. Javascript objects
  10. Javascript strings
  11. Javascript events
  12. Javascript errors
  13. Javascript DOM
  14. Javascript elements
  15. Javascript new windows
  16. Javascript date & time
  17. Javascript cookies
  18. Javascript print
  19. Javascript redirect
  20. Javascript void
  21. Javascript summary

Javascript DOM

Javascript contains a standard way to access and manipulate HTML documents and the elements within them. This standard is called the DOM.

This tutorial focuses on:

What is the DOM?

DOM stands for Document Object Model. The DOM is a W3C standard by which HTML documents and the elements within them are accessed through Javascript. For example, you can access and change the value in a textbox or change the title of a webpage with the DOM.

DOM objects

There are several DOM objects by which data can be accessed and manipulated.

Example:
<html> <head> <title>The window object</title> </head> <body> <input type="button" value="Click here for a message" onclick="window.alert('Hello. This is a message.');" /> <br /> <input type="button" value="Click here to see a prompt box" onclick="window.prompt('Enter some data');" /> <script type="text/javascript"> document.write("The URL of this page is " + window.location); </script> </body> </html>
Output:
Example:
<script type="text/javascript""> document.write("The domain of this page is " + document.domain); document.write("<br />" + This page was last modified on " + document.lastModified); </script>
Output:
Example:
<script type="text/javascript""> document.write("Name of web browser: " + navigator.appName); document.write("<br /> + "Cookies are enabled: " + navigator.cookieEnabled); document.write("<br />" + "Java is enabled: " + navigator.javaEnabled()); </script>
Output:
© Copyright 2013-2014 Landofcode.com
Terms of use | Privacy policy | Copyright information