Christoph M. Becker
6/7/2014 4:24:00 PM
Dr J R Stockton wrote:
> I have a little list (G&S is on the radio at the moment) of links to
> images. I want thumbnails when I hover over part of a list element.
>
> So far, I have little images appearing, but they increase the height
> of the list element, which I do not want; I want them to overlay,
> rather than push aside. Can they be shown without altering the
> previous "typesetting", and if so how? I have tried z-index
> variously, but not necessarily correctly. Otherwise I will
> presumably have to use a minimum-size minimum-chrome pop-up window.
>
> I currently have (not optimised) for onmouseover :-
>
> function Rodent(e) { e = e || window.event
> var hic = e.target || e.toElement // target is not in IE8
> hic.Elem = document.createElement("img")
> hic.Elem.src = List[hic.Wich].URL
> hic.Elem.align = "top"
> hic.Elem.style.width = "10%"
> hic.Elem.style.height = "10%"
> hic.Elem.style.zIndex = "-66"
> hic.ban = 0
> hic.parentNode.appendChild(hic.Elem) }
As others have already pointed out, this is more a CSS related issue,
and should be asked and discussed in a proper newsgroup. Solutions have
been already presented in
<news:53931a6b$0$6672$9b4e6d93@newsspool3.arcor-online.net>.
If you prefer, you most likely can stick with your current HTML markup,
and insert the img elements on the client side (assuming that ECMAScript
support is available there). However, it doesn't seem to be necessary
to do that in a mouseover event listener, what would save you the
trouble to store references to these images in properties of host objects.
Assuming a slight variation of the HTML markup presented in my post in
c.i.w.a.stylesheets, namely
<ul id="img-list">
<li><a href="...">...</a></li>
<li><a href="...">...</a></li>
</ul>
you could use something like the following to insert all img elements
permanently (put the script element at the bottom of the body element,
for instance).
<script>
(function () {
var imgList = document.getElementById("img-list"),
anchors = imgList.getElementsByTagName("a");
for (var i = 0, n = anchors.length; i < n; ++i) {
var anchor = anchors[i],
img = document.createElement("img");
img.src = anchor.href;
anchor.insertBefore(img, anchor.firstChild)
}
}());
</script>
--
Christoph M. Becker