469,643 Members | 1,486 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,643 developers. It's quick & easy.

Preload Image in Docwrite

I'm looking for an example of using a single preloaded image, where a
few images are loaded in a document.write.

Can anyone help with a simple example (as I'm still a novice in
javascript).

TIA
Bruce
Jul 20 '05 #1
3 1285
Bruce wrote on 16 feb 2004 in comp.lang.javascript:
I'm looking for an example of using a single preloaded image, where a
few images are loaded in a document.write.

Can anyone help with a simple example (as I'm still a novice in
javascript).


You cannot load something "in" a document.write.

What is the purpose of your quest?

Perhaps you can refrase youe question?

document.write is mostly only useful when the setup(!) of a page should be
dynamic. Dynamic image preloading does not need document.write.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 20 '05 #2
"Evertjan." <ex**************@interxnl.net> wrote in message news:<Xn********************@194.109.133.29>...
You cannot load something "in" a document.write.
What is the purpose of your quest?
Perhaps you can refrase youe question?
document.write is mostly only useful when the setup(!) of a page should be
dynamic. Dynamic image preloading does not need document.write.


I have a working page that uses a mapped image. When the user presses
one of the mapped areas (call them buttons), in some instances another
image (one of a few) is displayed (using a style sheet) and some text
appears (also using a style sheet). The trouble that the text appears
before the image, and that is why I need to preload those image(s), so
both appear at the same time. I am using document.write(s) to display
the second image (one of a few) and its accompanying text.

Bruce
Jul 20 '05 #3
Bruce wrote on 18 feb 2004 in comp.lang.javascript:
I am using document.write(s) to display
the second image (one of a few) and its accompanying text.


You cannot use document.write when the page is finished without destroying
the finished page and its script.

So better change the src or the innerHTML of a finished container:

<button onclick="document.getElementById('ImgPos').src='/img/New.jpg'">
change image</button>

<img src='/img/Old.jpg' id="ImgPos">

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by MALdito | last post: by
3 posts views Thread by Bob | last post: by
2 posts views Thread by jmhill | last post: by
2 posts views Thread by Albert Spencil | last post: by
1 post views Thread by Peter Fastré | last post: by
2 posts views Thread by =?Utf-8?B?Q2FzcGE=?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.