473,320 Members | 2,193 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Problem with preloading images on IE on Windows XP

Hi,

I'm trying to change images on a website without reloading the whole
page and use the following code to preload the images:

var preloadFlag = false;
function preloadImages() {
if (document.images) {
pic_moon2_click = newImage("images/moonpic2.jpg");
pic_moon3_click = newImage("images/moonpic3.jpg");
pic_moon4_click = newImage("images/moonpic4.jpg");
one_click = newImage("images/1.gif");
two_click = newImage("images/2r.gif");
three_click = newImage("images/3r.gif");
flour_click = newImage("images/4r.gif");
two_caps_click = newImage("images/mooncaps2.gif");
three_caps_click = newImage("images/mooncaps3.gif");
four_caps_click = newImage("images/mooncaps4.gif");
preloadFlag = true;
}
}
to change the images I use this code:

function changeImages() {
if (document.images && (preloadFlag == true)) {
for (var i=0; i<changeImages.arguments.length; i+=2) {
document[changeImages.arguments[i]].src =
changeImages.arguments[i+1];
}
}
}

when I click on the field that should make the images change (images
in three places are supposed to change at the same time, including the
one I'm clicking) I hand over two variables for each imagefield, the
name of the image tag that I want to change and the source of the new
image, I separate each group of two variables by a comma.

On my mac and various other platforms it seems to work fine but on
certain computers with Windows XP (IE6), not on all, the new images
don't load, but after clicking the button the image td is empty. If I
right click into the td and click on "Load Image" the right image
loads.

I tried to look at the page locally and then it all works fine even on
XP. So I thought it must have something to do with preloading the
images.

After that I tried a different code that doesn't use a preload
function but for some reason that didn't work either.

I have no idea what else to try... maybe someone here can help me :-)
Jul 23 '05 #1
2 1844
Ivo
"Julie" wrote
I'm trying to change images on a website without reloading the whole
page and use the following code to preload the images:

var preloadFlag = false;
function preloadImages() {
if (document.images) {
pic_moon2_click = newImage("images/moonpic2.jpg");


Where did you pick up this newImage thing? There is no such thing in
Javascript. There is the Image object, which takes two optional parameters
for its dimensions, not its source. You need to set the src in a separate
statement.
What you want to do is this:

if (window.Image) {
pic_moon2_click = new Image(); // note the space after "new"
pic_moon2_click.src = "images/moonpic2.jpg";
etc.

HTH
Ivo
Jul 23 '05 #2
> Where did you pick up this newImage thing? There is no such thing in
Javascript. There is the Image object, which takes two optional parameters
for its dimensions, not its source. You need to set the src in a separate
statement.
What you want to do is this:

if (window.Image) {
pic_moon2_click = new Image(); // note the space after "new"
pic_moon2_click.src = "images/moonpic2.jpg";
etc.

HTH
Ivo


I have a function called newImage

function newImage(arg) {
if (document.images) {
rslt = new Image();
rslt.src = arg;
return rslt;
}
}

that's why I think I don't need to set the src seperately here.
Do you think some platforms have a problem with that?
Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

22
by: Fabian | last post by:
var preload1 = new Image(); preload1.src = "/pic/yay.gif"; var preload2 = new Image(); preload2.src = "/pic/nay.gif"; The above is meant to preload image files, yes? Problem is, it doesnt seem...
6
by: michaaal | last post by:
Is this the correct way to preload an image...? Var Image1 = new Image() ....And then when I'm ready to use the image I can do this...? Button1.src=Image1.src ....Or am I just telling...
2
by: windandwaves | last post by:
Hi Gurus Preloading images has got to be JS 101. However, it does not seem to be working. Here is the function that I am using. I added the alerts to make sure it is working and all the right...
40
by: Geoff Cox | last post by:
Hello, I am still having problems - apologies if the answer is in previous postings! I now have, in the header, <sctipt> var myimages=new Array();
3
by: giladg22 | last post by:
Hi All, I need some help resolving a pretty tricky problem. I have a javascript application running from a CD. The script preloads between 500 to 1000 jpegs (about 40K each) to the IE. The IE...
2
by: sachaburnett | last post by:
Hi everyone! I'm new to Javascript and am finding so much useful information on this group, so thanks to you all! I have a question about preloading images for onmouseover/out effects and...
7
by: Inny | last post by:
Hello again, Im using the code below in a child page (popup), the images are called from the parent page. When the changer is running, the child page goes white between images. I realise this is...
7
by: Keith Hughitt | last post by:
Hi all, I am having trouble preloading images in a javascript application, and was wondering if anyone had any suggestions. Basically I have a bunch of images stored in a database as BLOBs. At...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.