qrayg
05-24-2005, 10:10 PM
I'm not a JS expert in the least but I've narrowed my problem down to this hunk of code:
var a, sTitle;
var anchors = document.getElementsByTagName ("a");
for (var i = 0; i < anchors.length; i ++) {
a = anchors[i];
sTitle = a.getAttribute("title");
if(sTitle) {
a.setAttribute("tiptitle", sTitle);
a.removeAttribute("title");
a.removeAttribute("alt");
a.onmouseover = function () {tooltip.show (this.tiptitle)};
a.onmouseout = function () {tooltip.hide ()};
}
}
What I'm trying to do is create a new attribute called "tiptitle" on any <a> tag that contains a "title" attribute. I then want to set the value of the tiptitle attribute to the value of the title attibute. Finally I want to remove the title attribute.
This works fine in IE but it returns "undefined" in Mozilla.
Does anyone know what I'm doing wrong?
var a, sTitle;
var anchors = document.getElementsByTagName ("a");
for (var i = 0; i < anchors.length; i ++) {
a = anchors[i];
sTitle = a.getAttribute("title");
if(sTitle) {
a.setAttribute("tiptitle", sTitle);
a.removeAttribute("title");
a.removeAttribute("alt");
a.onmouseover = function () {tooltip.show (this.tiptitle)};
a.onmouseout = function () {tooltip.hide ()};
}
}
What I'm trying to do is create a new attribute called "tiptitle" on any <a> tag that contains a "title" attribute. I then want to set the value of the tiptitle attribute to the value of the title attibute. Finally I want to remove the title attribute.
This works fine in IE but it returns "undefined" in Mozilla.
Does anyone know what I'm doing wrong?