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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T00:35:22+00:00 2026-06-07T00:35:22+00:00

This code is the core of a much larger script that works great in

  • 0

This code is the core of a much larger script that works great in almost all browsers. Yet it didn’t work in IE. So I’ve stripped it down and found that the image.onload isn’t firing in IE.

I’ve done some research, and I’ve guarded against it being an image caching problem. For one, the error occurs first time round before anything is cached, and, more importantly, the onload event is attached before the src.

I’m also reasonably sure I’m attaching the onload event in an IE compatible manner, so what gives, why don’t I get an alert?

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">             
            <script type="text/javascript">

        function generate(){
            var imageGen = document.createElement("img");
            imageGen.setAttribute('onload',"primer()"); 
            imageGen.setAttribute('src', "http://www.google.co.uk/images/srpr/logo3w.png");
            document.getElementById('image').appendChild(imageGen);
            }   

        function primer() { 
            alert("here now");
            }

        </script>
    </head>

    <body onload="generate()">
        <div id="image">

        </div>
    </body>
</html>

I’m hosting a version here

I only have access to IE8 unfortunately, so I don’t know if it persists across other versions, even so it needs to be fixed.

  • 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-07T00:35:23+00:00Added an answer on June 7, 2026 at 12:35 am

    First of all, events are not attributes and must not be set using setAttribute. It might, or might not work.

    Second, try creating image object instead of image element:

    var imageGen = new Image();
    imageGen.src = "http://www.google.co.uk/images/srpr/logo3w.png";
    imageGen.onload = primer;
    document.getElementById('image').appendChild(imageGen);
    

    Live test case – worked fine for me on IE9 and IE9 compatibility mode which should be like IE8.

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

Sidebar

Related Questions

I'm in a bit of a predicament with a much larger code than this,
I have this JSP code snippet: <%@ taglib uri=http://java.sun.com/jsp/jstl/core prefix=c%> <c:choose> <c:when test=${var1.properties[\Item Type\]
I keep on getting this error error: expected specifier-qualifier-list for core data code im
This Code: Something = new Guid() is returning: 00000000-0000-0000-0000-000000000000 all the time and I
I am doing dual core optimization by multi-threading, and it works like this: If
I'm running this scala code on a 32-bit quad-core Core2 system: def job(i:Int,s:Int):Long =
This code gives me an empty result. I expect it to print out the
This code attempts to dynamically switch the class of the StateContainer div from StateOne
This code snippet is from C# in Depth static bool AreReferencesEqual<T>(T first, T second)
This code basically translates characters based on position in one string to the character

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.