ReMaX
01-14-2008, 03:12 PM
Heyho,
I've tried to write a jscript function with parameters for every link in a certain list. The script works fine but I cannot write the events?!
Simple example:
<ul id="menu">
<li><a href="#"><span>willkommen</span></a></li>
<li><a href="#"><span>olfdsre</span></a></li>
<li><a href="#"><span>lkjhre</span></a></li>
<li><a href="#"><span>dskjhre</span></a></li>
<li><a href="#" class="active"><span>ohre</span></a></li>
<li><a href="#"><span>olfd</span></a></li>
<li><a href="#"><span>olfdkjhre</span></a></li>
</ul>
<script type="text/javascript">
var menucontainer;
var linklist = new Array(16);
var z=0;
if (document.all)
menucontainer = document.all["menu"];
else if (document.getElementById)
menucontainer = document.getElementById("menu");
linklist = menucontainer.getElementsByTagName("a");
for (z=0;z<=linklist.length-1;z++)
{
linklist[z].onMouseOver = alert("test"); // works only one time: when loading script!
}
</script>
If I write "onMouseOver" as parameter in every link it works, of course, but the links are generated out of a database and the output is like in the structure above. I also do not want to write more than necessary in the great xhtml structure of my design :cool:!
I thought that would be the most easiest thing but - I am a JS beginner :rolleyes:.
Help, please!
greetings
Max
I've tried to write a jscript function with parameters for every link in a certain list. The script works fine but I cannot write the events?!
Simple example:
<ul id="menu">
<li><a href="#"><span>willkommen</span></a></li>
<li><a href="#"><span>olfdsre</span></a></li>
<li><a href="#"><span>lkjhre</span></a></li>
<li><a href="#"><span>dskjhre</span></a></li>
<li><a href="#" class="active"><span>ohre</span></a></li>
<li><a href="#"><span>olfd</span></a></li>
<li><a href="#"><span>olfdkjhre</span></a></li>
</ul>
<script type="text/javascript">
var menucontainer;
var linklist = new Array(16);
var z=0;
if (document.all)
menucontainer = document.all["menu"];
else if (document.getElementById)
menucontainer = document.getElementById("menu");
linklist = menucontainer.getElementsByTagName("a");
for (z=0;z<=linklist.length-1;z++)
{
linklist[z].onMouseOver = alert("test"); // works only one time: when loading script!
}
</script>
If I write "onMouseOver" as parameter in every link it works, of course, but the links are generated out of a database and the output is like in the structure above. I also do not want to write more than necessary in the great xhtml structure of my design :cool:!
I thought that would be the most easiest thing but - I am a JS beginner :rolleyes:.
Help, please!
greetings
Max