How to show a preloader when loading images from a remote server

sanvp

New Member
I require to show a loading icon when I am assigning a URL to an image element. I have looked at the other questions on this site which only details about how to show graceful pre-loader for images when loading a page. What I require is to show the pre-loader after the page is loaded. There are 2 scenarios to what I am looking for which I have explained below.[*]I dynamically create an DOM Image Element and assign a URL to this Element. While doing so, it takes about a 2-3 seconds to show the image on the element and the area goes blank for those 2-3 seconds. What I would need to do is to show a pre-loading icon and hide it once the image has been loaded. [*]I dynamically create an DIV Image Element and assign a URL to \[code\]background:url()\[/code\]. While doing so, it takes about a 2-3 seconds to show the image on the element and the area goes blank for those 2-3 seconds. What I would need to do is to show a pre-loading icon and hide it once the image has been loaded. How can I achieve showing the preloader for both the scenarios?
 
Back
Top