Home Answers Viewqa JavaScriptQuestions Show spinner while loading image using JavaScript

 
 


samar
Show spinner while loading image using JavaScript
1 Answer(s)      2 years and 5 months ago
Posted in : JavaScript Questions

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 Pages:
Show spinner while loading image using JavaScript
Show spinner while loading image using JavaScript  Hello sir I am... of seconds before the chart changes. What i want do is it shows spinner while loading.... function chartOnClick() { //How long to show the spinner for in ms (eg 3 seconds
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
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
maximize an image using javaScript
maximize an image using javaScript  Write the code to maximize an image using javaScript
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
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
Spinner in Flex4
Spinner control in Flex4: Flex4 introduced a new a Spinner control which was not available in MX. In Flex4 Spinner control is called a Spark component... in Spinner control. The tag of Spinner control is <s:Spinner>
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  
Class.forName will do while loading drivers
Class.forName will do while loading drivers  What Class.forName will do while loading drivers
Javascript Examples
are going to show an image on clicking the checkbox. This is done by using...; JavaScript Zoom in and Zoom out Here we are providing you an example to show the image... using JavaScriptJavaScript getElementById innerHTML In JavaScript
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
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
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
Loading updated values - JSP-Servlet
Loading updated values  In my jsp project profile updating is one of that part. While updating i have to show updated values in choice list for birthday date column. How can we show the previously updated values in choice list
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
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... the current date. Here is the code: <html> <h2>Show
JavaScript - JavaScript Tutorial
is JSP using JavaScript I this example we will show you how to validate... according to their requirements while using JavaScript. There is a method... with the Java Scripting language. You will learn the benefits of using JavaScript
JavaScript Show Hide table
JavaScript Show Hide table...; In this section, we are going to show and hide table on clicking the button using...='javascript:showTable();' value='show'> <input type='button' onClick
How to design a loading logo
How to design a loading logo You might have seen loading icon... their home page so that they need any icon to show that. We are going to design an animated loading icon so follow now. New File: First we have to take a new
JSP hide and show tables
JSP hide and show tables In this tutorial, you will learn how to hide and show html tables using javascript in jsp. Here is an example of simple jsp code which is having a table consists of database data and a Go button. Using
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
JavaScript - JavaScript Tutorial
JavaScript with Link and Image. Using onMouseOver and onMouseOut... of using JavaScript in your programming.    Fundamentals... in JavaScript In this section you will learn example to use while, do-while and switch
JavaScript - JavaScript Tutorial
JavaScript with Link and Image. Using onMouseOver and onMouseOut... of using JavaScript in your programming.    Fundamentals... in JavaScript In this section you will learn example to use while, do-while and switch
Show Hide Text Javascript - Java Beginners
Show Hide Text Javascript  Please tell me how to show hide text using Java Script
Dynamic loading of Combo box list using servlet - JSP-Servlet
Dynamic loading of Combo box list using servlet  I have the category..., retrive it in a servlet, By using this value communicate to the data base...(); while(rs.next()){ request.setAttribute("userid", rs.getString(2
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
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
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
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
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
JavaScript Slideshow
, you will learn how to create slide show using JavaScript. To display a series... show using html <img> tag. By its name attribute, we enables JavaScript... into the changed image. By using the JavaScript method setTimeout("
Issue with Javascript
using javascript that for the question we should get 4 options and for the each...Issue with Javascript  Hi I created arrays in javascript in following...]= " How many iphone styles are present in the image? "; Questions[1]= " What
Loading JApplet into Servlet - Applet
Loading JApplet into Servlet  Hi, I am in need of loading javax.swing.JApplet in a Serlvet. This should work for all the browsers. Firefox 2.0... classs. As of now, we are using tag to load JApplet, which is working only
JQuery Spinner
JQuery Spinner   I am working in JQuery and i want to create SPinner for getting Credit Card Expiry Date in the form of MM/yyyy . Will you Please help me How to create the Spinner . Thank you. Regards Arun
loading page in div
loading page in div  how to load another web page in div?   <div name="iframe" id="iframe"></div> <iframe id="foo" name="foo" src="http://www.w3schools.com/"></iframe> //and 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
Calendar In JSP Using JavaScript
Calendar In JSP Using JavaScript   ... in JSP using JavaScript. We created the following files for the application... "Click here To Show Event".. Open a viewevent.jsp
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.  
how to display the image in center - Ajax
how to display the image in center  i want to dispaly the image as center of the screen using javascript..while i am clicking the button ..any one give me the code for this one
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>â
JavaScript Checkbox getElementById
() for checkbox in JavaScript. In the given example we are going to show an image on clicking the checkbox. This is done by using the JavaScript method getElementById...="check" onclick="showImage()" /> Show Image <form> <
Image Item Using Canvas Example
Image Item Using Canvas Example       This example is will show you how to create the image at the top center of the screen. The following are the methods used
dynamic image change javascript
dynamic image change javascript  How to display images in JavaScript dynamically
Image
Image  how to insert image in xsl without using xml. the image was displayed in pdf..Please help me
Image
Image  how to insert image in xsl without using xml. the image was displayed in pdf..Please help me
Image
Image  how to insert image in xsl without using xml. the image was displayed in pdf..Please help me
I want Image Album like -orkut and Facebook Using Struts 1.2
I want Image Album like -orkut and Facebook Using Struts 1.2  photo... in a database. it is neccessary..... I am using a link "Photo Gallery" to show... = "select * from image"; ResultSet rs = stmt.executeQuery(strQuery); while
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

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.