Hi, trevorturk. Thanks for your question.
The reason the script you linked to doesn't work in Safari is because
Safari's support for the cellIndex property of cells is broken - it
always returns '0', no matter which cell you click on. This means it
will always try to sort the first column, no matter which one you
click on.
Fortunately, the fix is fairly simple, if a little less neat than the
original solution. You can make it work correctly in Safari by making
the following changes:
Change the line:
cell.innerHTML = '<a href="#" class="sortheader"
onclick="ts_resortTable(this);return false;">'+txt+'<span
class="sortarrow"> </span></a>';
to:
cell.innerHTML = '<a href="#" class="sortheader"
onclick="ts_resortTable(this, '+i+');return false;">'+txt+'<span
class="sortarrow"> </span></a>';
Change the line:
function ts_resortTable(lnk) {
to:
function ts_resortTable(lnk, clid) {
And change the line:
var column = td.cellIndex;
to:
var column = clid || td.cellIndex;
There's an example of the patched code at
http://hexx.net/ga/sorttable/example.html and you can download an
already-modified copy from http://hexx.net/ga/sorttable/sorttable.js.
If you have any questions, please feel free to request a clarification.
--wildeeo |