Forum Moderators: open
The info can be provided in pretty much any way in the html - I prefer class, since id's are supposed to be unique, and the same keyword can appear more than once on a page.
My first attempt was to create an array of images within the specified div by using getElementByTagName, and then trying to src the image with a given uri string appended with the class name of that image. This gave me an error of the type 'missing name after . operator'.
I switched to using id instead of class, and no longer get this message, but the image does not swap on mouseover. This is what I currently have in the head:
<script>
function docpix()
{
if(document.getElementByTagName)
var x = document.thecode.getElementByTagName('img');
else return;
for (var i=0;i<x.length;$i++)
{
x[i].onmouseover = function () {
var im = new Image;
im.src = '/docbox.php?m=manual&l=' + x[i].id;
this.src = im.src;
}
x[i].onmouseout = function () {im.src= 'i/tr.gif';
this.src = im.src;}
}
}
</script>
images in the html body are like this:
<img src="i/in.gif" id="defined" />
This tag would be meant to grab /docbox.php?m=manual&l=defined in the hover state.
The function is called with:
<body onload=docpix> in the main body tag.
The version which registered the error was the same, except with x[i].class instead of x[i].id , and a class name in the images instead of an id name. Any tips or thoughts on the matter much appreciated. Once I get this down I'll worry about the css details of getting it to position properly as a tooltip, this isn't necessary at the moment.
I suppose I could also just use the old onmouseover / onmouseout in the links themselves, but since these keywords can occur a few hundred times in one document, it'd be great to save the bandwidth and do it with the replacement script.