...

View Full Version : Javascript "Loading..."



rettgoings
08-23-2010, 06:47 PM
Is there an easy was to handle loading? I have an image/text gallery and want to display "Loading..." when the JavaScript is loading the next object.


var currentMain = 0;
var currentMainT = 0;
var current_position=0;
var all_links="";

function init(){
all_links=document.getElementById('gallery').getElementsByTagName('a');
all_links[0].style.color="#7d3d3d";
ShowMain(current_position);
}

function color_me(element,color){
element.style.color=color;
}

function Prev(){
color_me(all_links[current_position],'#000000');
if((current_position-1)>-1){
current_position=current_position-1;
}
else{
current_position=(all_links.length-1);
}
ShowMain(current_position);
// ShowMainT(current_position);
color_me(all_links[current_position],'#7d3d3d');
}

function direct_selection(number){
all_links[current_position].style.color="#000000";
current_position=number;
ShowMain(current_position);
all_links[current_position].style.color="#7d3d3d";
}

function Next() {
color_me(all_links[current_position],'#000000');
if((current_position+1)<all_links.length){
current_position++;
}
else{
current_position=0;
}
ShowMain(current_position);
// ShowMainT(current_position);
color_me(all_links[current_position],'#7d3d3d');
}

function ShowMain(which){
currentMain = which;
currentMainT = which;
if ( currentMain < 0 ) currentMain = 0;
if ( currentMainT < 0 ) currentMainT = 0;
if ( currentMain > imgList.length-1) currentMain = imgList.length-1;
if ( currentMainT > clientData.length-1) currentMainT = clientData.length-1;
document.getElementById('mainImg').src = imgList[currentMain];
document.getElementById('mainText').innerHTML = clientData[currentMainT];
var PD = document.getElementById('Pg');
var PD2 = document.getElementById('Pg2');

document.getElementById("mainText").style.display = 'inline';
// return false;
}

onload = function() { ShowMain(0); }
onload = function() { ShowMainT(0); }
//-->

maxetime
08-23-2010, 09:14 PM
Hi,

When I want a loading graphique between image change I just put it has background img on the div so when the innerHTML changes we see the background image until the next innerHTMl loads

rettgoings
08-23-2010, 11:22 PM
Well I don't think its possible with that way with the code I have. The current images stay until the next image loads.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum