5
var tr = document.createElement('tr');
tr.setAttribute("onclick",p.onrowclick+"("+row.id+")");

Hi, the above works fine for me in Firefox. I can't find the correct syntax for a workaround in IE.

I'm using IE8.

StuR
  • 12,042
  • 9
  • 45
  • 66
  • Did you consider using a JavaScript library? – Šime Vidas Oct 18 '10 at 11:08
  • The above code is what I used with a jQuery extension called Flexigrid so that I could add an onclick event to the tr. I just threw that code in without regard to jQuery or an 'easier approach'. I thought that if it wasn't working with the above code I'd have the same problem with any other way of assigning an onclick to a tr in IE. – StuR Oct 20 '10 at 08:56

2 Answers2

3

Don't set events like this. Pass it a proper function:

tr.onclick = function() { p.onrowclick(...); }  
Pekka
  • 442,112
  • 142
  • 972
  • 1,088
0

Works on IE only, but not the suggested way:

var tr = document.createElement('<tr onclick="p.onrowclick('+row.id+')">');
Kernel James
  • 3,752
  • 25
  • 32