views:

1098

answers:

1

i have an html table which is built dynamically. i have an event handler attached to the table which sorts a column when the column is clicked. I wish to force a column sort (i.e. sort the table by a specific column) once the page has finished loading.

currently, i use document.getElementById(ElementName).click(); This works in IE but not FireFox. How can i achieve the same effect in Firefox?

+1  A: 

Instead of calling the click handler, just invoke the handler function directly. Assuming that your handler is on a span containing the column name, it might look something like:

<span id='defaultColumn' onclick='sortBy(this);'>Column</span>

So you would do:

sortBy( document.getElementById('defaultColumn') );

Or maybe

<span id='defaultColumn' onclick='sortBy("Column Name");'>Column Name</span>

which would give you

sortBy( document.getElementById('defaultColumn').innerHTML );
tvanfosson
+1 if you put the HTML attributes in double quotes ;)
sirlancelot