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.image s) {
pic_moon2_click = newImage("image s/moonpic2.jpg");
pic_moon3_click = newImage("image s/moonpic3.jpg");
pic_moon4_click = newImage("image s/moonpic4.jpg");
one_click = newImage("image s/1.gif");
two_click = newImage("image s/2r.gif");
three_click = newImage("image s/3r.gif");
flour_click = newImage("image s/4r.gif");
two_caps_click = newImage("image s/mooncaps2.gif") ;
three_caps_clic k = newImage("image s/mooncaps3.gif") ;
four_caps_click = newImage("image s/mooncaps4.gif") ;
preloadFlag = true;
}
}
to change the images I use this code:
function changeImages() {
if (document.image s && (preloadFlag == true)) {
for (var i=0; i<changeImages. arguments.lengt h; i+=2) {
document[changeImages.ar guments[i]].src =
changeImages.ar guments[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 :-) 2 1903
"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.image s) { pic_moon2_click = newImage("image s/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
> 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.image s) {
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? This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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 to be doing so in practice. Any idea where Im going wrong? Could it
be that things work differnetly when in an attached .js file?
--
--
|
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 Button1 to use the same source path as Image1?
|
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 alerts show up, yet when I do my
mouseover, it still takes about a second (only the first time) to load the
image (thumbnail).
Am I missing anything?
|
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();
|
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 immediatly decompresses the
jpegs, essentially using up too much memory.
I have a few limitations working against me:
A) Since the jpegs reside on a CD, it is crucial that I preload them to
the IE in order to not incur the seek time that is...
| |
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 found so many different ways to do it on the Net but am not sure
about something. Right now I have the following code inside my <head>
tag:
|
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 happening because the Images are not cached (yet) on the users browser.
I tried preloading images with the 2nd code below in the childpage head
and in the parent page head and both. no joy, dosent seem to actually 'preload' the pics. (i also gave...
|
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
any given point in time a subset of those images is displayed on-
screen. At certains times I want to swap out those on screen with new
ones from the database, and do some as seamlessly as possible.
So what I've tried to do is first create Image...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |