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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T00:45:09+00:00 2026-06-09T00:45:09+00:00

I’m trying to get the onError event to work but so far it only

  • 0

I’m trying to get the onError event to work but so far it only works in Internet Explorer 9. I have tried several codes but basically it comes down to this:

<img class="a_toc_image" src="' + asap.imgurl + '" onError="this.src=\'images/no_image.png\';" />
  • Internet Explorer 9:
  • Success: Gets an image from our database
  • Fail : Displays no_image.png

  • Chrome 20.0.11:

  • Success: Gets an image from our database
  • Fail : Just whitespace

  • Firefox 14.0.1:

  • Success: Gets an image from our database
  • Fail : Broken image icon

Many mostly aesthetical variants on this code ( such as leaving out or putting in ” or ‘ ) yield similar results. This specific variant yielded a stack overflow in Iexplorer but otherwise nothing changed:

<img class="a_toc_image" src="' + asap.imgurl + '" onError=this.src="\images/no_image.png()" />

Who can tell me what is going wrong here and why it will only work in Iexplorer 9?

Thanks!

-Addition:

When using “inspect element” in Chrome on an image that fails to load I see this:

<img class="a_toc_image" src="images/no_image.png" onerror="this.src='images/no_image.png';">

So it looks like it is generating the correct output but for some reason won’t show the image, correct? I have tried to put a .jpg instead of .png just now (maybe Chrome would just not show .png images) but that also does not solve anything.

-Addition 2, preceding code

// General functions

var open_mask = function () {

    //Get the screen height and width
    var maskHeight = $(document).height();
    var maskWidth = $(window).width();

    //Set height and width to mask to fill up the whole screen
    $('#mask').css({'width':maskWidth,'height':maskHeight});

    //transition effect     
    $('#mask').fadeIn(1000);    
    $('#mask').fadeTo("fast",0.7);  

};

var center_dialog = function (dialog) {

    //Get the window height and width
    var winH = $(window).height();
    var winW = $(window).width();

    var dialog_top =  (winH/2-dialog.height()/2) + $(window).scrollTop();
    var dialog_left = (winW/2-dialog.width()/2) + $(window).scrollLeft();

    dialog_top = (dialog_top >= 0) ? dialog_top : 0;
    dialog_left = (dialog_left >= 0) ? dialog_left : 0;

    dialog.css('top',  dialog_top);
    dialog.css('left', dialog_left);
};


//function that creates posts  

var updatepostHandler = function(postsJSON) {

    $.each(postsJSON,function(i,asap) {  

        if(i === 0) {
            first = asap.first;
            last = asap.last;
        } else {
            if(asap.type === 'article') {
                $('<div></div>')                        //create the HTML
                            .addClass('solid')  
                    .html('<div class="titbox">' + asap.title + '</div> \
                        <div class="boxinsolid"> \
                        <div class="aubox">' + asap.authors + '</div> \
                        <div class="doibox"> DOI: ' + asap.doi + ' </div> \
                        <div class="joubox">' + asap.journal + '</div> \
                        </div> \
                        <div class="imgbox"> \
                                <img class="a_toc_image" src="' + asap.imgurl + '" onError="this.src=\'images/no_image.png\';" /> \
                        </div>')        

                            .click(function(e) {  
                        open_details(e, asap.id);
                                })  
                            .prependTo($('#container'))
                    .slideDown('slow') 
            } else if(asap.type === 'ad') {
                $('<div></div>')                        //create the HTML
                            .addClass('ad')  
                    .html('<div class="titbox">' + asap.title + '</div> \
                        <div class="boxinsolid"> \
                        <div class="aubox">' + asap.authors + '</div> \
                        <div class="doibox">&nbsp;</div> \
                        <div class="joubox">' + asap.company + '</div> \
                        </div> \
                        <div class="imgbox"> \
                                <img class="a_toc_image" src="' + asap.image + '" onError="this.src=\'images/no_image.png\';" /> \
                        </div>')                        

                            .click(function(e) {  
                        open_details(e, asap.ad_id);
                                })  
                            .prependTo($('#container'))
                    .slideDown('slow') 
            }



        };

          });

};
  • 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-09T00:45:10+00:00Added an answer on June 9, 2026 at 12:45 am

    I tried it in Chrome and FF it seems that the problem is the (unnecessary) backslashes before your single quote characters.
    See this example: http://jsfiddle.net/Yapad/

    So, you should use this code, instead of your code:

    <img class="a_toc_image" src="' + asap.imgurl + '" onerror="this.src='images/no_image.png';">
    

    Edit:
    Sidestepping the issue with proper handling of asap.imgurl would look like this:

    <img class="a_toc_image" src="' + (asap.imgurl != "" ? asap.imgurl:"/images/no_image.png") + '">
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a French site that I want to parse, but am running into
I am trying to loop through a bunch of documents I have to put
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
Basically, what I'm trying to create is a page of div tags, each has
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
this is what i have right now Drawing an RSS feed into the php,

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.