[thelist] java syntax for strings

jeff jeff at members.evolt.org
Sun Apr 1 13:09:09 CDT 2001


patrick,

:~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
: From: Patrick Berry
:
: Avoid using numbers in image name attributes
: in IE.
:   <img name="guy1" src="..."> --> Bad
:   <img name="guyone" src="..."> --> Better
: I can't tell you why, I just know it bit me
: in the ass once...
:~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

more than likely it bit you in the ass because you had some other element on
the page with the same name.  this would create a problem in any browser out
there.  one way to avoid that, provided the items with the same name are
different types of objects, is to access those items via their collection.
so, instead of this:

document.guy1.src

access it via the images collection:

document.images['guy1'].src

as a sidenote, this is also how you can avoid the use of the
processor-intensive eval().  so this:

for(i = 1; i < 10; i++)
{
  eval('document.guy' + i + '.src = \'dot.gif\'');
}

could become this:

for(i = 1; i < 10; i++)
{
  document.images['guy' + i].src = 'dot.gif';
}

good luck,

.jeff

name://jeff.howden
game://web.development
http://www.evolt.org/
mailto:jeff at members.evolt.org





More information about the thelist mailing list