Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Jul 2010
    Posts
    37
    Thanks
    17
    Thanked 0 Times in 0 Posts

    Javascript "Loading..."

    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.

    Code:
    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); }
    //-->

  • #2
    New to the CF scene
    Join Date
    Aug 2010
    Location
    Montreal, Canada
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #3
    New Coder
    Join Date
    Jul 2010
    Posts
    37
    Thanks
    17
    Thanked 0 Times in 0 Posts
    Well I don't think its possible with that way with the code I have. The current images stay until the next image loads.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •