brothercake
03-24-2003, 07:01 PM
I want to bind event-handlers to each item in a complex list. What I'm doing at the moment is such a hack I'm almost embarrased to post it .... this:
tree = document.getElementById('list');
data = tree.innerHTML;
data = data.replace(/<li/ig,'<li onmouseover="openMenu(this,false)"');
tree.innerHTML = data;
I told you it was a hack ;) But it works .. that much is certain.
Is there a better way? I can't see how elm.onevent or addEventListener could be used, because they can't pass values. What else can I do?
I need an x-browser solution, by which I mean moz, safari/konqi, O7 and IE5. I don't mind if it takes a different approach for each one ... or even if there's a better way for the others and I still have to use this hack for IE.
Any improvement would be welcome; this method is a big onload process overhead I could well do without.
tree = document.getElementById('list');
data = tree.innerHTML;
data = data.replace(/<li/ig,'<li onmouseover="openMenu(this,false)"');
tree.innerHTML = data;
I told you it was a hack ;) But it works .. that much is certain.
Is there a better way? I can't see how elm.onevent or addEventListener could be used, because they can't pass values. What else can I do?
I need an x-browser solution, by which I mean moz, safari/konqi, O7 and IE5. I don't mind if it takes a different approach for each one ... or even if there's a better way for the others and I still have to use this hack for IE.
Any improvement would be welcome; this method is a big onload process overhead I could well do without.