K
Kameleonten
To make my navigation menu work in IE I have used this script. But it
doesn't work with classes. So when I now want to use a CMS that
genererates the navigation hierarchy that uses class instead of ID it
fails. How do I modify it so it works with CLASS instead of ID?
startList = function() {
if (document.all && document.getElementById) {
navRoot = document.getElementById("nav");
for (i=0; i<navRoot.childNodes.length; i++) {
node = navRoot.childNodes;
if (node.nodeName=="LI") {
node.onmouseover=function() {
this.className+=" over";
}
node.onmouseout=function() {
this.className=this.className.replace(" over", "");
}
}
}
}
}
window.onload=startList;
----------------------------------------
Here is my experiment that doesn't work:
function getElementbyClass(classname){
var partscollect;
var inc=0
var alltags=document.all? document.all :
document.getElementsByTagName("*")
for (i=0; i<alltags.length; i++){
if (alltags.className==classname)
partscollect=alltags
}
}
startList = function(){
if (document.all && document.getElementByClass) {
navRoot = document.getElementByClass("bulletmenu");
for (i=0; i < navRoot.partscollect.childNodes.length; i++) {
node = navRoot.partscollect.childNodes;
if (node.nodeName=="LI") {
node.onmouseover=function() {
this.className+=" over";
}
node.onmouseout=function() {
this.className=this.className.replace(" over", "");
}
}
}
}
}
I don't have any javascript experience, but with Java I have .
doesn't work with classes. So when I now want to use a CMS that
genererates the navigation hierarchy that uses class instead of ID it
fails. How do I modify it so it works with CLASS instead of ID?
startList = function() {
if (document.all && document.getElementById) {
navRoot = document.getElementById("nav");
for (i=0; i<navRoot.childNodes.length; i++) {
node = navRoot.childNodes;
if (node.nodeName=="LI") {
node.onmouseover=function() {
this.className+=" over";
}
node.onmouseout=function() {
this.className=this.className.replace(" over", "");
}
}
}
}
}
window.onload=startList;
----------------------------------------
Here is my experiment that doesn't work:
function getElementbyClass(classname){
var partscollect;
var inc=0
var alltags=document.all? document.all :
document.getElementsByTagName("*")
for (i=0; i<alltags.length; i++){
if (alltags.className==classname)
partscollect=alltags
}
}
startList = function(){
if (document.all && document.getElementByClass) {
navRoot = document.getElementByClass("bulletmenu");
for (i=0; i < navRoot.partscollect.childNodes.length; i++) {
node = navRoot.partscollect.childNodes;
if (node.nodeName=="LI") {
node.onmouseover=function() {
this.className+=" over";
}
node.onmouseout=function() {
this.className=this.className.replace(" over", "");
}
}
}
}
}
I don't have any javascript experience, but with Java I have .