472,789 Members | 1,160 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,789 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 1815
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: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth

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.