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

  • Home
  • SEARCH
  • 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 8795609
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T23:25:31+00:00 2026-06-13T23:25:31+00:00

I am getting an inconsistent error with my script. Often times everything works fine,

  • 0

I am getting an inconsistent error with my script. Often times everything works fine, however, every now and then I am getting the following error: ReferenceError: fadeIn is not defined

Here is the relevant code:

In the <head>

    <script type="text/javascript" charset="utf-8">
        window.fadeIn = function(obj) {
            var item = $(obj).parent();
            item.fadeIn(1000);
        }
    </script>

In the <body>

 <div class="item" style="display:none"><img onload="fadeIn(this)" src="/uploads/thumbs/{{image.url}}"><br>{{ image.description }}</div>

Again, The images are loading and fading in most of the time but every now and then I get the error and the images do not fade in.

Is there a better way to approach this? Or just something I’m missing?

  • 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-13T23:25:33+00:00Added an answer on June 13, 2026 at 11:25 pm

    You need to make sure your code is loaded after the DOM is ready.

    window.onload = function(){
        var fadeIn = function(obj) {
             var item = $(obj).parent();
             item.fadeIn(1000);
        };
    };
    

    … that’s a partial fix, but not really, because in all likelihood, your <img/> tags with the onload hardcoded into them is going to try to fire that method before it’s available.

    Since you’re using jQuery anyhow, you should look at something like this:

    $(function() {
        $(".item img").load(function(){
             $(this).fadeIn(1000);
        });
    });
    

    and get rid of the hardcoded onload from your img tags.

    It should be noted, also, that there are caveats listed on the .load() API page:

    From the docs (http://api.jquery.com/load-event/):

    Caveats of the load event when used with images

    A common challenge developers attempt to solve using the .load() shortcut is to execute a function when an image (or collection of images) have completely loaded. There are several known caveats with this that should be noted. These are:

    It doesn’t work consistently nor reliably cross-browser
    It doesn’t fire correctly in WebKit if the image src is set to the same src as before
    It doesn’t correctly bubble up the DOM tree
    Can cease to fire for images that already live in the browser’s cache

    A better solution might be to hide the images with CSS, then after the load event is fired, fade them in.

    (Even better than that might be to let browser behavior be, as your results may be mixed, and users seeing a blank page might instead hit the reload button thinking their browser glitched, before your animations are complete. … just a friendly warning that these kinds of DOM manipulations can sometimes have unintended side-effects on user behavior!)

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

Sidebar

Related Questions

I'm getting inconsistent accessibility error in the following declaration: public static class Helper {
I am getting the following error in VisualStudio Inconsistent accessibility: parameter type 'mynamespace.ProgressChangedEvent' is
I'm getting the following error: Inconsistent accessibility: parameter type 'RR.DAL.LINQSqlCLient.StaticReport' is less accessible than
I am getting inconsistent datatype error message and I am not sure why. I
I am getting the following error when I try to push my app to
I am using the AsyncTask and I am getting the following error in the
I have problem executing below stored procedure. I am getting error of ORA-00932: inconsistent
I am using proguard to obfuscate the code. I am getting the following error
We are getting this error java.sql.SQLException: OALL8 is in an inconsistent state when executing
Annoyingly I am getting a very inconsistent error that is difficult to understand. I

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.