I have a way below, but it doesnt seem to work in Firefox or Chrome, any ideas? Improvements? Changes completly? -
var wds_assets_for_preload = [
-
[0, "./images/buttons/drag_toolbar.gif"],
-
[0, "./images/buttons/dropdown_mouseover.png"]
-
]
-
var CurrentImage = new Image();
-
for(var i = 0; i < wds_assets_for_preload.length; i++)
-
CurrentImage.src=wds_assets_for_preload[i][1];
-
Thanks, Josh
9 3485 gits 5,390
Expert Mod 4TB
could you tell a bit more - what is not working correctly? typically it is an async process and you may use an onload-handler in FF for example to be sure that the image is loaded before further processing ... like in the following example: -
<html>
-
<script type="text/javascript">
-
-
function foo() {
-
var i = new Image;
-
-
i.onload = function() {
-
document.getElementsByTagName('body')[0].appendChild(i);
-
};
-
-
i.src = 'http://www.google.de/intl/de_de/images/logo.gif';
-
}
-
-
</script>
-
-
<body onload="foo();">
-
</body>
-
-
</html>
-
kind regards
Im not sure, I just noticed, after this "preload" the images in IE7 that are dynamicly set come up instantly, and in ff, they slowly popup, I assumed this meant that the preload worked in IE? :S
Thanks, Josh
to check whether an image is completely loaded I'd go for the image.complete property....
regards
gits 5,390
Expert Mod 4TB @Jezternz
i guess that is a caching issue ... just setting the src of an image loads the file but unless you use an onload or the complete-property you don't really 'know' when the sources are loaded completely.
kind regards
The json array is malformed! Wrong: -
var wds_assets_for_preload = [
-
[0, "./images/buttons/drag_toolbar.gif"],
-
[0, "./images/buttons/dropdown_mouseover.png"]
-
];
-
Should be: -
var wds_assets_for_preload = [
-
"./images/buttons/drag_toolbar.gif",
-
"./images/buttons/dropdown_mouseover.png"
-
];
-
There are no literal indexes for arrays in json! gits 5,390
Expert Mod 4TB
?? the OP just used an array that contains elements that are arrays itself ... and the construct is syntactically correct ... and even when it would be an ajax-response it would be correct syntax to be evaled when it is a string ... what if the first element of a subelement is needed for something else? how should it be transfered in such a structure that basicly seems to be an Array-structure? you just flattened the array and so dropped some information ... i think this would be a valid JSON-string in case it would be used as such ... but of course i could be wrong ;)
kind regards
yehhh, I have the 0's there as my array was a bunch of assets to preload. "0" just meant image, so they are supposed to be there :S
gits 5,390
Expert Mod 4TB
does it work with an onload or checking for the complete-property?
kind regards
Havent had any luck :( Have decided to scrap the image preload for now, I will likely try again later, bring this thread back up.again.
Sign in to post your reply or Sign up for a free account.
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...
|
by: Dave |
last post by:
Hi,
I have an app that uses rollover images, but the images are still pulled
from the web server during a mouseover instead of being pulled from memory.
The code is as follows:
the...
|
by: Julie |
last post by:
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...
|
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...
|
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: utahwrx |
last post by:
I currently have a Javascript application that randomizes about 200
images. The problem is that the images preload, which causes the entire
site to not come up until all the images are loaded. I'd...
|
by: littleark |
last post by:
Hi everybody,
I have a typical javascript images preloader, it works fine both on
Firefox and on IE in my intranet (local server).
It works fine on the Internet (remote server) in IE.
In...
|
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...
|
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...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
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...
|
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,...
|
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...
| |