[thelist] caption on images?

david.landy at somerfield.co.uk david.landy at somerfield.co.uk
Tue May 11 06:44:48 CDT 2004


Manuel, italPASTA(!), Tony, and David -- many thanks for all your replies.

The ones I like the most are:

1. <img id=image1 src=image.gif><label for=image1>Image Title</label>

This makes good sense logically in that it ties the image and its title
together by element - but I can't see how to format it so that the label
would always be under the image.

and 

2. The javascript method to use the dom to create a text element, using the
title attribute of the image (see below). Now... could dom be used to
replace the image with a single-cell table with the image, and a caption
element?

David

http://www.1976design.com/blog/archive/2003/11/25/captions/

<script type="text/javascript">
// Dunstan Orchard http://www.1976design.com/blog/

function extractImageTitles()
	{
	images = document.getElementsByTagName('img');
	for (var i = 0; i < images.length; i++)
		{
		var title = images[i].getAttribute('title');
		if ((title) && (title != ''))
			{
			if (title.match('http://', 'i'))
				{
				newlink = document.createElement('a');
				newlink.setAttribute('href', title);
				newlink.setAttribute('title', ('Go to ' +
title));
	
newlink.appendChild(document.createTextNode('Image source'));
				var newdiv = document.createElement('div');
				newdiv.className = 'caption';
				newdiv.appendChild(newlink);
				images[i].parentNode.appendChild(newdiv);
				images[i].removeAttribute('title');
				}
			else
				{
				var newdiv = document.createElement('div');
				newdiv.className = 'caption';
	
newdiv.appendChild(document.createTextNode(title));
				images[i].parentNode.appendChild(newdiv);
				images[i].removeAttribute('title');
				}
			}
		}
	}

window.onload = extractImageTitles;
</script>



-- 
David Landy, IT Consultant, Business Intelligence
Somerfield/KwikSave Support Centre
Whitchurch, Bristol, UK. Tel: 0117 301 8977
david.landy at somerfield.co.uk <mailto:david.landy at somerfield.co.uk>    
 
This is the true joy of life. The being used for a purpose 
Recognized by yourself as a mighty one. 
George Bernard Shaw


 
If you are not the intended recipient of this e-mail, please preserve the
confidentiality of it and advise the sender immediately of any error in
transmission. Any disclosure, copying, distribution or action taken, or
omitted to be taken, by an unauthorised recipient in reliance upon the
contents of this e-mail is prohibited. Somerfield cannot accept liability
for any damage which you may sustain as a result of software viruses so
please carry out your own virus checks before opening an attachment. In
replying to this e-mail you are granting the right for that reply to be
forwarded to any other individual within the business and also to be read by
others. Any views expressed by an individual within this message do not
necessarily reflect the views of Somerfield.  Somerfield reserves the right
to intercept, monitor and record communications for lawful business
purposes.


More information about the thelist mailing list