Michael Winter wrote:
> On 23/06/2005 14:24, Markus Ernst wrote:
>
> [snip]
>
>> if (document.getElementsByTagName) {
>> a = document.getElementsByTagName("a");
>> for (var i=1; i<a.length; i++) {
>> var element = a[i];
>> element.onmouseover = function() {
>> element.parentNode.className = "aktiv"; };
>> element.onMouseOut = function() {
>> element.parentNode.className = "passiv"; };
>> element.onFocus = function() {
>> element.parentNode.className = "aktiv"; };
>> element.onBlur = function() {
>> element.parentNode.className = "passiv"; };
>> }
>> }
>
> The problem is that you're forgetting about case-sensitivity: for
> instance, there is no recognised onMouseOut property, but there is a
> generally recognised onmouseout property. The same goes for onFocus
> and onBlur.
Thank you very much for your input. The case sensitivity issue does indeed
solve a part of my problem - now all four events are performed, but still
always on the last element.
I think I need to find a way to save a reference to a[i] which is not
overwritten by the following loop.
> However, you don't need a script to do what you're attempting. CSS is
> quite capable:
Yes I use this for the <a> element itself. The task is to highlight also the
containing element of this html structure:
<div class="passiv">
<a href="koepfe/paolo_tonti.html">Paolo Tonti</a>
<span>Werbung / Konzept / Graphic Design</span>
</div>
I don't know if CSS provides a syntax to address the parent element - but I
am sure that it would not be supported by today's common browsers anyway...
Of course I have a working solution with four event handlers in every link -
but I would be happy to find a solution that makes a maximum separation of
content and presentation.
--
Markus
Received on Tue Oct 18 02:47:54 2005