Show spinner while loading image using JavaScript

Show spinner while loading image using JavaScript

Hello sir

I am working on a web page which has .png image in middle of it. Other part of the page contains the set of links which , when clicked, the entire page reloads and looks exactly the same as before except for the chart in the middle of the page.

The problem is that when the user clicks on the link, it may take a couple of seconds before the chart changes.

What i want do is it shows spinner while loading image.

Please Reply ASAP and also give code.

Best regards

View Answers

December 11, 2010 at 3:40 PM

You can do this by using the power of setTimeout() method. This allows you set a timer to trigger a function call in the future, and calling it won't block execution of the current / other functions.

First, Position a div containing the spinner above the chart image, with it's css display attribute set to none:

<div>&nbsp;<img src="spinner.gif" id="spinnerImg" style="display: none;" /></div>

The nbsp stop the div collapsing when the spinner is hidden.

function chartOnClick() {
  //How long to show the spinner for in ms (eg 3 seconds)
  var spinnerShowTime = 3000

  //Show the spinner
  document.getElementById('spinnerImg').style.display = "";

  //Change the chart src
  document.getElementById('chart').src = '/charts/10.png';

  //Set the timeout on the spinner
  setTimeout("hideSpinner()", spinnerShowTime);
}

function hideSpinner() {
  document.getElementById('spinnerImg').style.display = "none";
}









Related Tutorials/Questions & Answers:
Show spinner while loading image using JavaScript
Show spinner while loading image using JavaScript  Hello sir I am... spinner while loading image. Please Reply ASAP and also give code. Best regardsADS..., Position a div containing the spinner above the chart image, with it's css display
maximize an image using javaScript
maximize an image using javaScript  Write the code to maximize an image using javaScript
Advertisements
loading image
animated loading image on 1st JSP while the request is being processed. If I use form submit , the animated loading does not show animated.I would like to know how to show animated loading image on regular form submit
Hide show HTML forms using javascript
Hide show HTML forms using javascript  How to hide a HTML form in my application using JavaScript?   HTML Code to create checkbox <...;div id="yourDiv"> ...other forms... </div> JavaScript function to hide
Exception while inserting image in oracle using java
Exception while inserting image in oracle using java  import java.sql.*; import java.io.*; class Oracle2 { public static void main(String args...()); System.out.println("Image length: "+f.length()); System.out.println("No.of rows
Adding image to database through jsp or HTML page ,while adding only image should show.
Adding image to database through jsp or HTML page ,while adding only image should show.   Adding image to database through jsp or HTML page,while adding only image should show. After that i need view that uploaded image from
Class.forName will do while loading drivers
Class.forName will do while loading drivers  What Class.forName will do while loading drivers
how to save uploaded image in database using javascript
how to save uploaded image in database using javascript  Please can you tell me how to store uploaded image in database using java I'll use...(form, file) { allowSubmit = false; if (!file) return; while (file.indexOf
loading image - Swing AWT
loading image  give me a source code to add any wallpaer of my PC as a background image to jpanel on a jframe
how to retrieve image from mysql database using java and show it in HTML img tag ?
how to retrieve image from mysql database using java and show it in HTML img tag ?  how to retrieve image from mysql database using java and show it in HTML img tag
how to show popup in javascript
how to show popup in javascript  How to show popup in javascript
How to access the image file from project folder itself while writing to pdf using itext?
How to access the image file from project folder itself while writing to pdf using itext?  I am writing a pdf using itext where i add a image in the beginning of the document. When i use image = Image.getInstance("C
Image Slide Show using 'Space gallery' plug-in
Image Slide Show using  'Space gallery' plug-in In this tutorial , we will create a slide show using 'Space gallery' plug-in .In this example , two tabs are given. in one tab 'Space gallery' slide show
JavaScript hide image
; In this section, we are going to show and hide image on clicking the button using the JavaScript. In the given example, we have defined an image using <img>... JavaScript hide image
changing an image based on checking checkbox using HTML & JavaScript, Please put div blocks
changing an image based on checking checkbox using HTML & JavaScript, Please...;script type="text/javascript"> function showImage...) { document.getElementById("image").style.visibility = 'visible
pre Page load display an image loading - JSP-Servlet
this. Thanks  Yes i have to display an loading image while page... some pages are loading very slow, while the page is processing we need to display a loading image. How to achieve this requirement. Thanks Manu  
javascript image not found
javascript image not found  javascript if image not found   <a href='$image'> <img alt='No Image' src='$image' onError="this.parentNode.onclick=function() {return(false);}"> </a>â
how to show random image in ASP.net?
how to show random image in ASP.net?  hello bros i saw in many websites..there is a programming of random image changing.... i want to use this in my... can do it.may be it will dot net or may javascript code..suggest me bros
JavaScript Show Date
JavaScript Show Date..., we are going to display the current date using JavaScript. You can see...; <h2>Show Date</h2> <script type="text/javascript">
dynamic image change javascript
dynamic image change javascript  How to display images in JavaScript dynamically
Program in javascript to show the current location
Program in javascript to show the current location  Hi All, Actually... loads...so, can you give me a simple program in javascript to show the current location in JavaScript? Thanks
JavaScript Show Hide table
JavaScript Show Hide table...; In this section, we are going to show and hide table on clicking the button using...' onClick='javascript:showTable();' value='show'> <input type='button
JavaScript move image
; This section illustrates you how to move an image on the window using JavaScript. In the following code, we have defined an image 'node.jpg' in order to move... JavaScript move image
java code using while loop
java code using while loop  
Show Image Scale
Show Image Scale       This section shows you the scales of image. To show scales of Image, an image is defined inside the class folder and calls the ImageIcon class to return
display image using jsp
display image using jsp  display image using jsp and phonegap on emulator of eclipse   Here is a simple jsp code that displays an image on browser. <%@ page import="java.io.*" %> <%@page contentType="image/gif
Email validation is JSP using JavaScript
will show you how to validate email address in you JSP program using JavaScript... Email validation is JSP using JavaScript.... In your JSP program you can use JavaScript to validate the email address
Image Movement using Swings
Image Movement using Swings  How to move image using Swings
Show image and text on same jsp page
Show image and text on same jsp page  Hi all, I have to display image and text on the same jsp page. The text and image are both retrived from mysql database. The image is shown correctly on seperate jsp page but when shown
delete an entry using JavaScript
delete an entry using JavaScript  How to delete an entry using JavaScript
Date object using JavaScript
Date object using JavaScript  What's the Date object using JavaScript
using for loop in javascript
using for loop in javascript  How to use for loop in JavaScript
Displaying images using Javascript
Displaying images using Javascript... to display images using javascript and css.For this we are going to make program named...;type="text/javascript" src="image-slideshow-5.js">
Show Hide Text Javascript - Java Beginners
Show Hide Text Javascript  Please tell me how to show hide text using Java Script
Hide/show Image by click
Hide/show Image by click In this tutorial ,we will discuss about how to display image by click using jQuery. In the below example, a image and two lines are given. By clicking on upper line , it will hide the image and the line
Show Limited Data Using jquery
Show Limited Data Using jquery  How to show limited results in JQuery? For example i have 10 results but only 5 need to be displayed. How to achieve it using JQuery?   See the JQuery example to show the limited fetch
xls to js using javascript
xls to js using javascript  ![how can we convert a xls file in js file using javascript][1
timer using javascript
timer using javascript  How to display timer on HTML page using JavaScript
insert image using hibernate
insert image using hibernate  Sir, Today I hadposted question regarding upload image, th answer you had given is using SQL, but I am using Hibernate to insert data in the same table where I want to insert image. Plz hlp me
Image using Java coding
Image using Java coding  Hai, Display image in pdf file using Java coding through Xsl file.. Please help me.. xsl file generate the pdf file
Uploading image using jsp
Uploading image using jsp  how to upload image using jsp. Already i tried, But that image file does not read. It returns only -1 without reading that image file ... I want know that solution using by u... Thanks, P.S.N.  
send mail using JavaScript
send mail using JavaScript  How can we send mail using JavaScript?   Hi friends, You can not send email directly using JavaScript. But you can use JavaScript to execute a client side email program send the email using
Show Image Reader and Image Writer by MIME Type
Show Image Reader and Image Writer by MIME Type... the Image Reader and Image Writer by by MIME Type.  To show the image reader and image writer by MIME Type, we have used ImageIO class of the package
Image name,image path into database and image into folder using jsp
Image name,image path into database and image into folder using jsp  How to insert image path and image name into oracle database and image into folder using jsp
how to show image as a link which path coming from database
how to show image as a link which path coming from database   iam not getting proper answer for it. I am using netbeans .the url coming instring from database ,want to display as image on jsp . please help me
Show Other Image Effects
Show Other Image Effects   ... To show image effects like sharpen, blur, show edge, reset ,etc, we have create... will get blurred. On clicking Show Edge button, only the edge of the image
How to show database values into graph using jsp?
How to show database values into graph using jsp?  How to show database values into graph using jsp
How to show database values into graph using jsp?
How to show database values into graph using jsp?  How to show database values into graph using jsp
How to make a loading symbol
How to make a loading symbol Learn here to create your own loading symbol that show the loading process in the website. New File: Take a new document. Draw a Circle: Draw a circle with this "f20b27" color by using
How to shift and unshift using JavaScript?
How to shift and unshift using JavaScript?  How to shift and unshift using JavaScript

Ads