Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
IMG ALT error handler
Old 02-24-2006, 09:50 AM IMG ALT error handler
dahak's Avatar
Skilled Talker

Posts: 60
Location: Romania
Trades: 0
Hello all,Please someone help me with this
i need to write an error handler that changes the alt test of an image to “Error Loading” if the image loading is not completed.

THANK YOU
dahak is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 02-24-2006, 10:20 AM Re: IMG ALT error handler
funkdaddu's Avatar
Web Design Snob

Posts: 635
Trades: 0
This simple one should work in Safari and IE, but doesn't work in FireFox:
HTML Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>

	<head>
		<meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
		<title>Untitled Page</title>
		<script type="text/javascript"><!--
function imgLoadErr(obj) {
	obj.alt = "Error Loading Image";
}
//-->
</script>
	</head>

	<body bgcolor="#ffffff">
		<p><img src="badlink.gif" alt="Image" height="316" width="349" border="0" onerror="imgLoadErr(this)"></p>
	</body>

</html>
Lemme look into the FireFox handler....

Last edited by funkdaddu; 02-24-2006 at 10:24 AM..
funkdaddu is offline
Reply With Quote
View Public Profile Visit funkdaddu's homepage!
 
Old 02-24-2006, 11:44 AM Re: IMG ALT error handler
funkdaddu's Avatar
Web Design Snob

Posts: 635
Trades: 0
This should work in Safari, IE, and Firefox, but it never refreshes the ALT attribute visually in FF, even though it reports it back correctly, anyone have any ideas?
HTML Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">

<html>

	<head>
		<meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
		<title>Untitled Page</title>
		<script type="text/javascript"><!--
function checkImgLoaded(id) {
	ckImg = document.getElementById(id);
	alert("image alt = " + ckImg.alt);
	testImg = new Image;
	testImg.src = ckImg.src;
	alert(testImg.complete);
	if (testImg.complete == false) {
		ckImg.alt = "Image Did Not Load";
		alert("image alt = " + ckImg.alt);
	}
}
//-->
</script>
	</head>

	<body bgcolor="#ffffff" onload="setTimeout('checkImgLoaded(\'imgName\')', 500);">
		<p><img src="" alt="Image Alt" width="500" height="500" border="0" id="imgName"></p>
	</body>

</html>
funkdaddu is offline
Reply With Quote
View Public Profile Visit funkdaddu's homepage!
 
Reply     « Reply to IMG ALT error handler
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.11493 seconds with 12 queries