Links

Lists

Latest Updates

Ruby On Rails List
Python list
Advanced Java
The JavaScript List
Apache Users
Full Disclosure
Linux Security

Search the archives!


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Javascript] Problems setting className


  • From: dnunes at gmail.com (diego nunes)
  • Subject: [Javascript] Problems setting className
  • Date: Fri Nov 11 10:46:46 2005

    I built, some time ago, a "function kit" to help when I'm
DOMScripting. One of the functions wasn't so efficient, 'cause it had
four obrigatory parameters. I've made some changes, creating the new
"cE 2.0" (which stands for "Create Element"). This function creates an
element, and set the id, className and value (with DOM, obviously).
The function is...

function cE(tN, tID, tCN, tC) {
  // createElement 2.0 -- <str tagName>, [str id, str class] [, (str |
obj) content]
  if (!document.createElement) return false; var nE, tER;
nE=document.createElement(tN);
  if (arguments.length > 1) { if (arguments.length == 2) { tC=tID;
tID=tCN=''; } if (valorValido(tID)) { nE.id=tID; }
    if (valorValido(tCN)) { nE.className=tCN; } if (tC) {
nE.appendChild( (typeof(tC)=='string')?cTN(tC):tC ); }
  } return nE;
}

    It's working quite fine in all browsers, but Firefox. It simply
refuses to apply the "className" (the third parameter). Even in
Internet Explorer it works, and in Opera. Does anybody knows why the
hell it's behaving this way?!

  Amplexos.

--
diego nunes