Saturday, September 17, 2011

Please wait while loading image - JavaScript


Today wanted add loading please wait kind of image when user click on likedin button from one of the page of site. Actually when user click on linkedin image it takes time to redirect from site to linkedin log-in. Between this time wanted to show an loading image so that user will get something is happening need to wait for a moment. So initially i thought to use many images & use them with time function it will work as i wanted. First googled to get some ready made script but i didn't get exactly. Later got this link which solved my problem so frequently that i never thought. Just went to that site, chosen the type of image i wanted & called that image in div tag & made that div style block on onClick event. That's it so simple & looks great.
Check the code which is pretty simple.
<scrip>
function showimage()
{
document.geElementById('showloadingimg').style.display = "block";
}
</script>
<a href='link to redirect' onClick="showimage()"><img src="image path" /> </a>
<div id="showloadingimg" style="display: none"><img src="here is path of that downloaded image" />
</div>

No comments:

Post a Comment