473,395 Members | 1,678 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,395 software developers and data experts.

Display loading graphic while images load in website.

jeremydowe
Hi,

I have noticed that quite a few websites use a preloading graphic (i.e spining circle) to show the that the site is loading images while the user waits.

How can I add this to my website?

At the moment, i have a request after click on a thumbnail which loads an image below using the innerHTML property.

For example:

// change innerhtml
function writeExplain(objectID, title, value, description){
var object = document.getElementById(objectID);
object.innerHTML = title + '<br>' + value + '<br>' + '<p class=clear>' + '</p>' + description;
}

i want something like this (but this code is not right)

// change innerhtml
function writeExplain(objectID, title, value, description){
var object = document.getElementById(objectID);
for(var i=0; i<document.images.length; i++) {
if(document.images[i]){
object.innerHTML = title + '<br>' + value + '<br>' + '<p class=clear>' + '</p>' + description;
}else{
object.innerHTML = '<div class=loading><img src=images/loading.gif /></div>';
}
}
}

What seems to happen is that the browser loads everything first on my one paged site (i am using a lot of layers to hide show content).

Have a look at my website: http://www.jeronimo.net.au/jeronimo.html

Any suggestions of what js functions i need to write to start this.

Jez.
Mar 14 '07 #1
3 2557
acoder
16,027 Expert Mod 8TB
Try having a layer that contains the image. Then set the visibility to visible and hide it when the image is ready.
Mar 15 '07 #2
Try having a layer that contains the image. Then set the visibility to visible and hide it when the image is ready.
what's the best way of checking if the image is loaded?
is that document.all or document.images[i] ?

jez.
Mar 15 '07 #3
acoder
16,027 Expert Mod 8TB
You can use onload on the image object. Or you can use the complete property, see link.
Mar 15 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Jeff Napier | last post by:
Is it a security restriction, or is it possible to display an image from a website other than the one on which the applet resides (without external php or javascript workarounds)? Thanks, - Jeff...
3
by: stan k. | last post by:
First of all let me clarify - I am not talking about having a bunch of images loaded all at once (or preloaded) and then controlling the display of the images after that point -- I know that can be...
4
by: www.MessageMazes.com | last post by:
Greetings, I'm working on a collection of free puzzle pages that serve as a feed to sale pages. My question is whether I can specify that some images load before others? If you visit...
0
by: speedcoder | last post by:
hi all, i'm stumped. my applet used to load images over the network. (it was actually designed by someone else.) yes, the applet used to load each image file independently over the network and...
10
by: eholz1 | last post by:
Hello Members, I am setting up a photo website. I have decided to use PHP and MySQL. I can load jpeg files into the table (medium blob, or even longtext) and get the image(s) to display without...
0
by: ShayHk | last post by:
Hi all Can someone tell me how to create a web Page which load images from a acertain directory for examle.. I placed on the remote server Images.. I want that the The webPage (on the server)...
3
by: yogarajan | last post by:
hi friend I want to display pdf file in my website pls any one guide me it is very urgent Thanks
4
by: Jethro | last post by:
hi guys, working with an inherited "project" only I have no vsprog file. The project is a web application. Is there anyway I can recreate the project file. At present I am loading it as a...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
marktang
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,...
0
Oralloy
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,...
0
jinu1996
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...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.