Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8997413
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:53:11+00:00 2026-06-15T23:53:11+00:00

I require to show a loading icon when I am assigning a URL to

  • 0

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.

  1. 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.

  2. I dynamically create an DIV Image Element and assign a URL to background:url(). 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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T23:53:11+00:00Added an answer on June 15, 2026 at 11:53 pm

    You can do it by using the load() event.

    When you first go to start the loading, change your image to show the preloader, or however you want to do it. Also, attach a “load” event to it.

    Then, once the image is loaded, remove your preloader and show the image.

    You’ll need to do a similar trick for the CSS related one (the background url). What you can do is load the image directly (by creating a new Image()), while settings the background url to your preloader icon.

    Then, once the image is loaded, do the switch. Since the browser only loads an image once regardless where it is used, it should have the same effect.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I require is to have a single stored procedure which can execute and show
I have a show page which is dynamically loading content based on tab-selection using
I have this script to show the dynamic sku on select option, but i
I have a form which upon its loading events retrieves data and populates some
I have following code for the UIAlertView Loading indicator which is not working and
I have the following code snippet and require to show only the first 2
I have a swf that requires flash 9, and I'm trying to show content
$(.container).hover( function(){ $(.child-1).hide(0); $(.child-2).show(0); },function(){ $(.child-1).show(0); $(.child-2).hide(0); }); A project I have requires that
require('fortunes') fortune('106') Personally I have never regretted trying not to underestimate my own future
require installed gems are not visible. Test with hpricot which I installed several times:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.