DHTML
  Home arrow DHTML arrow Page 8 - Rough Guide To The DOM (part 1)
Dev Shed Forums 
Administration  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Download TestComplete 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
OLM
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
DHTML

Rough Guide To The DOM (part 1)
By: Vikram Vaswani, (c) Melonfire
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 9
    2001-04-09

    Table of Contents:
  • Rough Guide To The DOM (part 1)
  • Back To Basics
  • Navigating The Family Tree
  • What's In A Name?
  • Ducks In A Row
  • Changing Things Around
  • Alternatives
  • Shazam!

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
     
    ADVERTISEMENT

    Route your faxes to your email inbox. Private, secure fax numbers available from CallWave. Choose your fax number.

    Rough Guide To The DOM (part 1) - Shazam!
    (Page 8 of 8 )

    The DOM also allows you to modify CSS properties of specific HTML tags - asthe following example demonstrates:

    <html> <head> <script language="JavaScript"> function disappear() { var obj = document.getElementById("mirage"); obj.style.display = "none"; } </script> </head> <body> <div id="mirage"> Now you see it... </div> <a href="javascript:disappear()">...now you don't!</a> </body> </html>

    I've done something similar in the very first example in this article -take a look at that one too, while you're at it.

    Using this technique, it's possible to apply almost any inline style to anelement on the page. Remember that style properties which are hyphenated -for example, "background-color" and "font-family" - need to be written as asingle word with the first character after the hyphen capitalized - forexample, "backgroundColor" and fontFamily". The next example shouldillustrate this clearly:

    <html> <head> <script language="JavaScript"> function transform() { var obj = document.getElementById("marvel"); obj.style.fontFamily = "Verdana"; obj.style.fontSize = "40pt"; obj.style.backgroundColor = "red"; obj.style.color = "black"; obj.style.textDecoration = "underline"; obj.style.textAlign = "center"; obj.style.letterSpacing = "10"; } </script> </head> <body> <div id="marvel"> Captain Marvel </div> <a href="javascript:transform()">shazam!</a> </body> </html>

    That's about it for the moment. In the second part of this article, I'll berunning through some simple code examples for simple JavaScriptapplications - image swaps, form validation and frame navigation - usingthe new DOM structures. I'll also be discussing the appendChild() andcreateNode() functions, which allow developers to add new elements to thedocument tree through program code. Don't miss it!
    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

     

       

    DHTML ARTICLES

    - Rough Guide To The DOM (part 2)
    - Rough Guide To The DOM (part 1)
    - Filters And Transitions In IE5
    - Understanding Embedded Fonts

     
    Accelerating Trading Partner Performance
     
    Competing on Analytics
     
    Cost Effective Scaling with Virtualization and Coyote Point Systems
     
    Five Checkpoints to Implementing IP Telephony
     
    Hosted Email Security: Staying Ahead of New Threats
     




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway