Posted by Toby Inkster on 10/08/05 12:16
Jeff Adams wrote:
> But can't you only have one background image?
Only one per element, yes.
Try:
<img src="foo.jpeg" alt="Foo" height="100" width="160" id="imgfoo">
<img src="bar.jpeg" alt="Bar" height="100" width="160" id="imgbar">
<script type="text/javascript">
function img2bg (i)
{
var e = document.getElementById(i);
var f = e.src;
e.src = null;
e.title = e.alt;
e.alt = '';
e.style.backgroundImage = "url(" + f + ")";
}
img2bg("imgfoo");
img2bg("imgbar");
</script>
The img2bg() function above takes a regular image, blanks it out and then
replaces it with a background image.
Example: http://examples.tobyinkster.co.uk/img2bg
--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact
[Back to original message]
|