Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

An alternative to onerror 1

Status
Not open for further replies.

bl4hster

Programmer
Jul 8, 2006
3
US
Ya, so i need to use the <img attribte onerror to load placeholder images on all dead image links, so that my page isnt full of that awful missing "X" thumbnails.

UNfortunatly onerror is not valid xhtml transitional.

The images are on REMOTE servers, so using a server side solution isnt really efficiant.

Anyway, my pages are not xhtml valid because of this one error. I feel like crap about it. If anyone has an xhtml valid solution, please share as uim sure there are many others looking for a solution to the same problem

 
Here's a quick solution... you might get a better one in the Javascript forum (forum216)

Code:
window.onload=function(){
	var imageList = document.getElementsByTagName('IMG');
	var i;
	for(i=0;i<imageList.length;i++){
		if(imageList[i].height <= 1){
			imageList[i].setAttribute('src','images/noImage.gif');
		}
	}
}

<honk>*:O)</honk>
Foamcow Heavy Industries - Web site design in Cheltenham and Gloucester
Ham and Jam - British & Commonwealth forces mod for Half Life 2
 
hey thanks a lot Foamcow. ill play with that snipplet, and get some ideas from the javascript forum. Thanks again for the help
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top