Re: mouseovers on crack

by Noone Special <pfarabee(at)indy.net>

 Date:  Mon, 25 May 1998 12:49:10 -0500 (EST)
 To:  paul brockmeyer <p-brockmeyer(at)nwu.edu>
 Cc:  hwg-graphics(at)hwg.org
 In-Reply-To:  nwu
  todo: View Thread, Original
Just goes to show you that strange things can happen when you index
images[] by image number instead of by name.
Here is a quote directly from the "Known Bugs" Section of the 2nd Edition
O'Reilly Javascript book (Rhino Cover)

---------------------------------------------------------------------------
p. 585-586

B.1.2 Table Bugs
There are a couple of JavaScript bugs in Navigator 3.0 that relate to HTML
tables.

B.1.2.1 Images in tables
When an <IMG> tag appears in a table cell, two JavaScript Image objects
will be created to represent it.  If the <IMG> tag appears in a table
nested within a table, four Image objects may be created. Only the last
Image object created for a given <IMG> tag has a working src property.
Because an unexpected number of Image objects are created, it is difficult
to correctly use the Document.Images[] array to refer to them.

As a workaround, give all you images names with the NAME attribute and
refer to them by name as properties of the Document object.  When
JavaScript creates multiple objects with the same name, it stores them in
an array by that name. If an image named "outside" is specified outside of
any HTML tables, you can refer to it as document.outside.  However, if an
image named "inside" is created within a table, two image objects will be
created, and tey can be referred to as document.inside[0] and
document.inside[1]. It is the latter image that has the correctly working
src property.

The following function demonstrates a workaround to this bug. Given an
image name, it returns the working Image object with that name.  It works
correctly for images that are not part of tables, and will continue to
work correctly even after this bug has been patched.

function getImage(image_name)
{
    var i = document[image_name];
    if (i.length)
       return i[(i.length - 1)]
    else
       return i;
}

---------------------------------------------------------------------------

You may be saying to yourself "But that will only return the image
object.. it won't let me write to it.. only read it"

Keep in mind that unless you specify a New object, if you assign a
variable to an existing object, it doesn't actually duplicate the object,
but makes the two variables hold the SAME object.  Any change to the
object referred to by one name automatically changes the other (because
they are actually the same object)

Example: My name is Patrick Clark Farabee
At work, I am called Clark.. My friends call me either Patrick or Farabee
Sometimes I am called Pat..
No matter what I am called, I am still the same person (object).
Whatever changes happen to me, those changes affect all of my instances
(Names)

Of course, if was to be CLONED (Tom = New Patrick)
Then the new object could evolve independently from me.  We would start
the same, but then would have no further connection.

Pat

Modern man is the missing link between apes and human beings.

HWG: hwg-graphics mailing list archives, maintained by Webmasters @ IWA

This page is part of a preserved archive of archives.hwg.org. The site is no longer active and its content is not maintained. For enquiries about this archive, write to archive(at)iwanet.org.