Search the archives!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Javascript] Image PreLoad
- From: nick at nickfitz.co.uk (Nick Fitzsimons)
- Subject: [Javascript] Image PreLoad
- Date: Thu Sep 21 15:24:02 2006
On 21 Sep 2006, at 20:51, Fl?vio Gomes wrote:
> heheheh, no, it's not sending mail =)
>
> There's no error message, and the "document.body" already exists.
>
> What I believe to be the problem is that I set a call to
> "document.body.appendChild(img)" (...)
>
> ===============
> img.onload = function(e) {
> alert("image loaded");
> document.body.appendChild(this);
> }
> ===============
>
> (..)
> inside the "onload handler" and, on Mozilla it seems to call the
> "onload" when a object is appended, making my code get locked in an
> infinite loop.
>
> Can you test this code for us on your Firefoxes and Safari? (It
> doesnt loop in IE6 Windows)
>
Hi,
I don't have any problem even when appending the image to the body on
Firefox 1.5.0.7 (Mac & Win), Opera 9 (Mac), Safari 2.0.4, or IE 6;
I've put up a test page at:
<http://www.nickfitz.co.uk/imageload.html>
with the script that's working for me in the page. It's not much (if
at all) different to your code. What version of Firefox are you
having problems with? If it's the same one, I'm not sure why it's not
working.
One minor difference between my and your code is that you set the
"src" property before attaching the onload handler, but when I
changed my code to do the same, it still worked. So that's one
potential issue you don't have to check :-) Oh, and it doesn't seem
to make a difference if one uses my approach of setting the image
source using setAttribute, or yours of setting the src property
directly - still works.
Cheers,
Nick.
--
Nick Fitzsimons
http://www.nickfitz.co.uk/
- Follow-Ups:
- [Javascript] Image PreLoad
- From: Terry Riegel
- [Javascript] Image PreLoad
- References:
- [Javascript] event handlers
- From: Bernu Bernard
- [Javascript] Image PreLoad
- From: Terry Riegel
- [Javascript] Image PreLoad
- From: Flávio Gomes
- [Javascript] Image PreLoad
- From: Terry Riegel
- [Javascript] Image PreLoad
- From: Flávio Gomes
- [Javascript] Image PreLoad
- From: Nick Fitzsimons
- [Javascript] Image PreLoad
- From: Flávio Gomes
- [Javascript] event handlers
- Prev by Date: [Javascript] Image PreLoad
- Next by Date: [Javascript] need help for my swaping function
- Previous by thread: [Javascript] Image PreLoad
- Next by thread: [Javascript] Image PreLoad
- Index(es):