Here’s the function:
[code]js.attr = function () {
var a = arguments;
var e = a[0];
var v = a[2];
var r = null;
a = a[1].toLowerCase();
if (js.def.obj(e, “dom”) && js.def.txt(a) && a !== “”) {
var s = ‘<‘ + e.nodeName.toLowerCase();
var l = s;
var c = e.attributes;
var o = true;
var n = “”, t = “”;
var d = true;
for (var i = 0;i < c.length;i++) {
n = c[i].nodeName.toLowerCase();
if (e.getAttribute(n)) {
t = c[i].nodeValue;
if (js.def.bol(t)) t = n;
l += ‘ ‘ + n + ‘=”‘ + t + ‘”‘;
if (n === a) {
if (js.def.txt(v)) {
o = false;
if (v !== “”) {
s += ‘ ‘ + n + ‘=”‘ + v + ‘”‘;
r = v;
}
} else if (t !== “”) r = t;
d = false;
} if (t === “”) o = false;
if (o) s += ‘ ‘ + n + ‘=”‘ + t + ‘”‘;
o = true;
}
} t = ‘>’ + e.innerHTML + ‘</’ + e.nodeName.toLowerCase() + ‘>’;
if (d && js.def.txt(v) && v !== “”) s += ‘ ‘ + a + ‘=”‘ + v + ‘”‘;
s += t; l += t;
o = e.parentNode;
v = o.innerHTML;
d = false;
t = false;
n = null;
for (i = 0;i < v.length;i++) {
if (d) {
if (t) {
if (!n) {
if (v[i] === ‘”‘) {
n = ‘”‘;
} else {
n = ‘ ‘;
v = v.substr(0, i) + ‘”‘ + v.substr(i);
} i++;
} if (v[i] === n) {
if (n === ‘ ‘) {
v = v.substr(0, i) + ‘”‘ + v.substr(i);
i++;
}
n = null;
t = false;
}
} else {
v[i] = v[i].toLowerCase();
if (v[i] === ‘>’) d = false;
else if (v[i] === ‘=’) t = true;
}
} if (v[i] === ‘<‘) d = true;
} v.replace(/ [a-z]+=(“”)? /, ” “);alert(v);
o.innerHTML = v.replace(l, s);
} return r;
};
My problem is that the tag name/s is not converted to lower case by force as it/they should be. every time I try the function the alert box produces html with upper case tags (this is IE by the way), the reason I’m not using getAttribute and related functions is because of IE’s problems. only reason that I’m converting case at all is because not all browsers produce the same case so I want to force the case to a single standard.
Edit: indecently this is part of a framework I’m building so feel free to use it if you think of a fix.