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 724379
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T06:12:56+00:00 2026-05-14T06:12:56+00:00

I have spent the whole day trying to make a script which on submit

  • 0

I have spent the whole day trying to make a script which on “submit” hides the form and shows hidden with animated progress bar. The problem is that Internet Explorer doesn’t show animated gif images in hidden divs. The images are static. I visited many websites and found a script which uses:

document.getElementById(id).style.backgroundImage = ‘url(/images/load.gif)’;

Finally, my script works in Internet Explorer, Firefox, Opera but… Google Chrome doesn’t display the image at all. I see only div text. After many tests I discovered the following: the only way to see the background image in Google Chrome is to include the same image somewhere in the page (outside of hidden div) with 1px dimensions:

<img src="/images/load.gif" width="1" heigh="1" /> 

This did the trick but… after this dirty solution Microsoft Explorer for some reason shows the image as static again. So, my question is: is there any way how to force Gogle Chrome to show the image? Thanks. This is my script:

<script language="JavaScript" type="text/javascript">

function ver (id, elementId){
if (document.getElementById('espera').style.visibility == "visible") {
    return false;
}else{
var esplit = document.forms[0]['userfile'].value.split(".");
ext = esplit[esplit.length-1];
    if (document.forms[0]['userfile'].value == '') {
        alert('Please select a file');
        return false;
    }else{
        if ((ext.toLowerCase() == 'jpg')) {
            document.getElementById(id).style.position = 'absolute';
            document.getElementById(id).style.display = 'inline';
            document.getElementById(id).style.visibility = "visible";
            document.getElementById(id).style.backgroundImage = 'url(/images/load.gif)';
            document.getElementById(id).style.height = "100px";
            document.getElementById(id).style.backgroundColor = '#f3f3f3';
            document.getElementById(id).style.backgroundRepeat = "no-repeat";
            document.getElementById(id).style.backgroundPosition = "50% 50%";

        var element;
            if (document.all)
                element = document.all[elementId];
            else if (document.getElementById)
                element = document.getElementById(elementId);
            if (element && element.style)
                element.style.display = 'none'; 

            return true;
        }else{
            alert('This is not a jpg file');    
            return false;
        }
    }
}
}  
</script>


<div id="frmDiv">
<form  enctype="multipart/form-data" action="/upload.php" method="post" name="upload3" onsubmit="return ver('espera','frmDiv');">
<input type="hidden" name="max_file_size" value="4194304" />
<table border="0" cellspacing="1" cellpadding="2" width="100%">
<tr bgcolor="#f5f5f5">
<td>File (jpg)</td>
<td>
<input type="file" name="userfile" class="upf" /></td></tr>
<tr bgcolor="#f5f5f5">
<td>&nbsp;</td>
<td>
<input class="upf2" type="submit" name="add" value="Upload" />
</td></tr></table></form>
</div>


<div id="espera" style="display:none;text-align:center;float:left;width:753px;">&nbsp;<br />&nbsp;<br />&nbsp;<br />&nbsp;<br />
&nbsp;<br />Please wait...<br />&nbsp;
</div>
  • 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-05-14T06:12:56+00:00Added an answer on May 14, 2026 at 6:12 am

    Try:

    (new Image).src="/images/load.gif";
    

    The big G itself uses this technique to pre-load DNS lookups on their homepage.


    UPDATE
    Due to the boggling -1 I received…I need to explain why the above may work to the numbskulls that downvote when they don’t understand the possibilities of a given solution.

    Google Chrome may very well be “intelligently” choosing which resources to download by analyzing if they will actually be displayed on the page (similar to how browsers don’t download every background-image:url(image) in a CSS file). If this is true the the following may also be true:
    If the time the “load.gif” image is intended to be displayed is LESS than the time it takes for the image to be downloaded then it will appear like the image is not displayed at all (even though it is just being downloaded).

    By pre-loading the image using the ‘(new Image).src =”image.gif”;’ approach we make sure the image will be ready in the browser’s cache and thus immediately available when needed.

    As to why Internet Exploder is only showing one frame I’m not sure. There must be other variables in the page causing this behavior (long running script, limit number of loops encoded in the GIF itself, ?).

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

Sidebar

Related Questions

I have spent the whole day trying to make my application use threads but
I have spent almost the whole day trying to find a solution to this
Ok, I have just spent the whole day playing with DomDocument and creating some
I've spent over a day trying to figure this out, I have looked at
I have spent most of a day trying to understand why Java cannot compile
I've spent the whole day googling and deleting and inserting trying to implement this
I have spent the entire day trying to get this code snippet to work:
I have uploaded the whole screenshot of the mail which is sent to my
Have spent an hour trying to solve this - but to no avail. I'm
I have spent the afternoon trying to wrap my mind around how to translate

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.