Ik ken geen Javascript, maar toch is het me gelukt om dit in elkaar te flanzen:
Ik heb heel veel geprobeerd te vervangen etc, maar ik kom er maar niet achter waarom dit niet draait in IE6/7.
Zien jullie het zo snel?
Bedankt,
Joachim
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
| //Sequence of the background colors from the menu items, from left to right.
var backgrounds = ["blue", "green", "pink", "purple"];
//Gives the menu item wich has the class 'active' the same background as what it should get in the function 'MenuColorChange'.
function MenuActiveColor() {
var ActiveLi = $('.active').attr('id');
var Number = ActiveLi.replace(/[^0-9]/g, '');
var ActualNumber = Number - 1;
document.getElementById(ActiveLi).setAttribute('style', "background: url(\"images/" + backgrounds[(ActualNumber % backgrounds.length)] + ".png\") no-repeat top;");
}
//Gives the menu items a style when hovering over it, in the sequence of the setting in the variable 'backgrounds', on top.
function MenuColorChange() {
for (var i = 0; i <= 10 ; i++) {
document.getElementById("custom-menu-item-id-" + (i + 1)).setAttribute('onMouseOver', "this.style.backgroundImage='url(images/" + backgrounds[(i % backgrounds.length)] + ".png)';");
document.getElementById("custom-menu-item-id-" + (i + 1)).setAttribute('onMouseOut', "this.style.background='none'; MenuActiveColor();");
}
}
// Load both functions when the document loads.
window.onload = function() {
MenuActiveColor();
MenuColorChange();
} |
Ik heb heel veel geprobeerd te vervangen etc, maar ik kom er maar niet achter waarom dit niet draait in IE6/7.
Zien jullie het zo snel?
Bedankt,
Joachim