Electric Type

Multimedia

About Us

News

Help

NAME, ID, and CLASS in Dynamic HTML and JavaScript Image Arrays

Page 3 — Which Browsers Can Read 'em?

Then the time came when we all had to graduate. We got jobs in new media and suddenly our perception of the world changed. We slaved away at the keyboards, coding whirlwind HTML. Strangely, I saw everything as HTML. Shvatz became an image tag. When I think of him, this is what I see in my mind.

    <img src="/98/05/stuff/shvatz.gif" name="shvatz" id="craigAdamSchwartz" class="counterCultureMedia">

My girlfriend thinks that I always talk in JavaScript, HTML, and CSS. But I talk about Shvatz in terms of style and behavior, which is of course separate from his structure. So if I see him at work and want to know if he's lost some weight, I say:

    function politeConversation() { 
    	if(document.images['shvatz'].width < oldWidth) {
    	document.writeln('Have you cut your hair?'); } }
    

Or when I got an email from the Justice Department asking for a description of Craig Adam Schwartz (I think someone had been working with too many ActiveX controls), I replied:

    #craigAdamSchwartz { height: 72in; 
    					 width: 38in; 
    					 color: gold; 
    					 background-color: bisque; 
    					 position: absolute; 
    					 left: -190080000in; 
    					 top: -6336000in; 
    					 visibility: visible; } 
    

When the Justice Department asked for a description of that guy in my counterculture media CLASS, I gave this description:

    .counterCultureMedia { float: left; margin: 0; page-break-after: always; clear: none; }

This was imprecise on the part of the Justice Department because all of us from that CLASS shared those same characteristics. After a lengthy manhunt, they realized their error, apologized to Shvatz, and took #fredJohnson into custody.

To distinguish Shvatz from that other weirdo Shvatz, we just run through the entire collection of people named Shvatz in our heads and pick out the one that is in our CLASS.

    function whosWho() { for(i=0; i < document.all('shvatz').length; i++) {
    
    if(document.all('shvatz')(i).className == 'counterCultureMedia'; ourShvatz = document.all('shvatz')(i); } } } 

So now I trust you know a lot more about Shvatz than you ever thought you would. You know now that if you are referring to him in JavaScript, in Netscape 3, Netscape 4, or Internet Explorer 4, using NAME will work if Shvatz happens to be an image, link, window, or form name. If you are using a CSS-enabled browser, you can specifically describe #craigAdamSchwartz by using his ID attribute, or you can describe all the members that share the same CLASS attribute. Internet Explorer 4 can also refer to Shvatz (by NAME or by ID) regardless of what type of HTML tag he is. Furthermore, if there is more than one Shvatz on your page, you can loop through the collection (an array) of Shvatzes and test them for some condition, such as CLASSNAME, to see if you have the correct Shvatz.

Getting the correct Shvatz is important. If I may leak a little trade secret, that's what 50 percent of our engineering staff does; they search for the correct Shvatz.




Dynamic HTML  

Frames  

HTML Basics  

Stylesheets  

Tables  

XML  

Javascript  

Database Connections  

Intro To Perl  

HTML 4.0  

User Blogs

Screen Shots

Latest Updates

Contact Us

Valid HTML 4.01!
Valid CSS!

Breadcrumb

© ElectricType
Maintained by My-Hosts.com
Site map | Copyright | Disclaimer
Privacy policy | Acceptable Use Policy
Legal information.