Thanks, Jscheuer1! Of course, I have already packed everything in an external .js-file and in functions. At the end of my page code I only write <script type="text/javascript">linkinit();</script> to execute the script, start loving javascript and I am finished with this problem.
I made this script because the client needs a menu on which the linktext of the linklogo on which you were with you mouse last stays visible.
For further visitors (see html-structure above):
Code:
var typecontainerid="menu";
var menucontainer;
var linklist = new Array(16);
function linkinit()
{
var i=0;
var mouseover;
menucontainer = document.getElementById(typecontainerid);
linklist = menucontainer.getElementsByTagName("a");
for (i=0;i<linklist.length;i++)
{
mouseover = function() { lastlink(this.getElementsByTagName("span")[0].firstChild.data,menucontainer); };
linklist[i].onmouseover = mouseover;
}
}
function lastlink(linkname,container)
{
var i=0;
for (i=0;i<=linklist.length-1;i++)
{
if (linkname==linklist[i].getElementsByTagName("span")[0].firstChild.data)
linklist[i].getElementsByTagName("span")[0].style.display = "block";
else
linklist[i].getElementsByTagName("span")[0].style.display = "none";
}
}
By the way, the menu is generated by wayfinder, a snippet for MODx, an open source cmf which I can recommend every cms developer!!!
Bookmarks