By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,442 Members | 1,316 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,442 IT Pros & Developers. It's quick & easy.

Preload Image in Docwrite

P: n/a
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
Share this Question
Share on Google+
3 Replies


P: n/a
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

P: n/a
"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

P: n/a
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.