471,624 Members | 2,059 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,624 software developers and data experts.

explain the "new Image();"

Currently using the "document.images" to "preload" images - not for
future pages, but for the page being loaded. I got it from
http://www.dynamicdrive.com/dynamici...agetooltip.htm

Its a nice script - pops up an img on mouseover.

I understand that its downloading SOMETHING - but its not rendering....

THE QUESTION: How does "preloading" these images (into cache, as I have
read) affect page size, page load, etc. I cannot find anything
specific regarding this.
CODE EXAMPLE:
if (document.images) {
var theImgs = new Array();
for (var i=0; i<messages.length; i++) {
theImgs[i] = new Image();
theImgs[i].src = "myimg.jpg";
}
}

Jun 16 '06 #1
1 1871

mm*****@gmail.com wrote:
Currently using the "document.images" to "preload" images - not for
future pages, but for the page being loaded. I got it from
http://www.dynamicdrive.com/dynamici...agetooltip.htm

Its a nice script - pops up an img on mouseover.

I understand that its downloading SOMETHING - but its not rendering....

THE QUESTION: How does "preloading" these images (into cache, as I have
read) affect page size, page load, etc. I cannot find anything
specific regarding this.
CODE EXAMPLE:
if (document.images) {
var theImgs = new Array();
for (var i=0; i<messages.length; i++) {
theImgs[i] = new Image();
theImgs[i].src = "myimg.jpg";
}
}


The images will cause the page to show the loading... gizmo in the
status bar until everything is preloaded, but if you preload in an
onload handler (rather than freestanding within script tags) the page
will display without waiting on the images to download. However, while
the images are downloading, all JS events are suspended in most
browsers. So if someone has dialup and you try to prefetch a large
image, and they mouse over a dynamic menu (for example) the menu
options won't display until the image finishes downloading. I don't
know how many browsers this affects, though.

Jun 17 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Mr.Clean | last post: by
5 posts views Thread by Mark Woodward | last post: by
1 post views Thread by XIAOLAOHU | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.