WrormLogsmola
New Member
I do something like that to handle a missing image and replace it by background color\[code\]<td width="34"><img onError="handleError(this, '#fff', 'fail');" src="'. $profileImg .'" alt="" height="'.$imgHeight.'" /></td>\[/code\]And that's the Javascript function that handles that:\[code\] function handleError(elem, colorCode, state){ if ((typeof(elem.onerror) === 'function' && state === 'fail') || (elem.width === 0) ){ elem.style.backgroundColor = colorCode; console.log(colorCode); } }\[/code\]The console.log line shows that firefox goes in there but won't display the background color ...PS: I tried also using JQuery..What am I doing wrong ?