Frank Carr wrote:
"Todd Cary" <to**@aristesoftware.com> wrote in message
news:GC******************@typhoon.sonic.net...
Please shorten your attribution. Omitting superfluous information
like the message-ID makes it only an attribution _line_ which eases
reading of discussions and makes it worse otherwise.
I am very new to JavaScript, so I just copied some javaScript and made a
few mods. How can I get around the pre-loading? Any help you can lend
is greatly appreciated.
Here's a little snippet from a page of mine...
function ShowPicture(nID)
{
document.getElementById('imgShow').width = arPictures[nID][3];
document.getElementById('imgShow').height = arPictures[nID][4];
document.getElementById('imgShow').src="images/" + arPictures[nID][1];
}
The above is highly inefficient, error-catching, bad style and thus
not to be recommended at all.
Zeroth, it is bad style since you directly refer to global variables
(`arPictures').
First, document.getElementById(...) is a method of the W3C-DOM.
You do not check for its support which is error-catching:
http://pointedears.de.vu/scripts/test/whatami
Second, it is more efficient to retrieve the reference once and
use it (several times) afterwards *if* it is _valid_:
if (document.getElementById)
{
var o = document.getElementBid(...);
if (o)
{
o.width = ...;
o.height = ...;
o.src = ...;
}
}
Third, user agents who support the document.getElementById(...)
method of W3C-DOM Level 2 also support its document.images[...]
collection and accessing it is even more efficient. More, the
collection is also backwards compatible as it is part of the
so-called "DOM Level 0" originating from Netscape Navigator 3.0
and Internet Explorer 3.0:
if (document.images)
{
var o = document.images[...];
if (o)
{
// ...
}
}
See
http://www.w3.org/TR/DOM-Level-2-HTML/
for details and consider (using) the source code of
http://pointedears.de.vu/scripts/test/hoverMe/
instead.
HTH
PointedEars
--
If you really think there's a bug [in MS Word] you should report a bug.
Maybe you're not using it properly. Have you ever considered that?
(Bill Gates in FOCUS no. 43, October 23, 1995, pages 206-212)