M
matty
Hello,
here is an example of what is driving me totally crazy. This example
will show that the first call to "doit()" will print 30 times the image
with only one call to the server. Then I have a timeout and call doit()
again, and this time, it downloads the picture 30 times!!!! It doesn't
even time to finish downloading the pictures before the next timeout
kicks off and if I let it go for a minute or two i have like 300 calls
to download the same image trying to be downloaded!
I heard about a bug in IE that would require to preload the images
using a hidden div, but that didn't work. I see that google maps manage
to not having to reload the image and gets it from cache. What am I
doing wrong? This works perfectly in Firefox (i.e. it uses the cache
and calls the server just once).
<html>
<body>
<div id="yo">yo</div>
<script language="javascript">
var im = document.createElement('IMG');
im.src = '../common/flags/US.gif';
function test() {
var tr = document.createElement('tr');
var td = document.createElement('td');
td.appendChild(im.cloneNode());
tr.appendChild(td);
var t = document.createElement('table');
var tb = document.createElement('tbody');
tb.appendChild(tr);
t.appendChild(tb);
return t;
}
function doit() {
document.getElementById('yo').appendChild(test());
setTimeout("doit()", 3000);
}
doit();
</script>
</body>
</html>
here is an example of what is driving me totally crazy. This example
will show that the first call to "doit()" will print 30 times the image
with only one call to the server. Then I have a timeout and call doit()
again, and this time, it downloads the picture 30 times!!!! It doesn't
even time to finish downloading the pictures before the next timeout
kicks off and if I let it go for a minute or two i have like 300 calls
to download the same image trying to be downloaded!
I heard about a bug in IE that would require to preload the images
using a hidden div, but that didn't work. I see that google maps manage
to not having to reload the image and gets it from cache. What am I
doing wrong? This works perfectly in Firefox (i.e. it uses the cache
and calls the server just once).
<html>
<body>
<div id="yo">yo</div>
<script language="javascript">
var im = document.createElement('IMG');
im.src = '../common/flags/US.gif';
function test() {
var tr = document.createElement('tr');
var td = document.createElement('td');
td.appendChild(im.cloneNode());
tr.appendChild(td);
var t = document.createElement('table');
var tb = document.createElement('tbody');
tb.appendChild(tr);
t.appendChild(tb);
return t;
}
function doit() {
document.getElementById('yo').appendChild(test());
setTimeout("doit()", 3000);
}
doit();
</script>
</body>
</html>