
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

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> <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";
}
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.