swapNode in Firefox
This is for you lazy guys out there. The Microsoft DOM extension swapNode() is a quite handy feature when dealing with Ajax and stuff, however Firefox lacks this method and I figured I'd share the solution I'm using.
This solution doesn't require you to update your behaviours if you are using them. The functions references to the two nodes you want to swap.
function swapNodes(item1,item2)
{
var itemtmp = item1.cloneNode(1);
var parent = item1.parentNode;
item2 = parent.replaceChild(itemtmp,item2);
parent.replaceChild(item2,item1);
parent.replaceChild(item1,itemtmp);
itemtmp = null;
}

Detta är min alldeles högst personliga blogg där jag skriver om än det ena än det andra.
Ibland skriver jag ofta(re) ibland väldigt sällan. Jag skriver delvis säsongsbetonat då jag är ett stort Formel 1-fan och delvis om mitt jobb/hobby som programmerare. Mer om mig hittar du 

Kommentarer
I'll keep a credit to this page when i use this function.
But I do not require you to credit me for it =)
I calling following
function replaceNodes(){
var myt=document.getElementById('mytable');
var n1 = myt.lastChild.childNodes[0].childNodes[1];
var n2 = myt.lastChild.childNodes[0].childNodes[2];
document.swapNode ? n1.swapNode(n2) : swapNodes(n2,n1);
}
Looks like you are trying to manipulate table-cells, judging from your getElementById('mytable') and Firefox doesn't allow you to do that. It's a limitation in Firefox.
So it's either that or something else that is wrong in your implementation since I also use FF 1.5.0.6 and the site I'm using my function in still works with FF under both Windows and Linux.
Also worth mentioning that this method (as opposed to the others I've tried) doesn't break any events you might have bound to the elements you are swapping.
Thanks again :-)
I'm glad you found it useful.
I didn't realized that my code doesn't break events but I guess that it makes the function even more useful! =)
This seems to work fine on table ROWS in Firefox, as long as you remember two things:
1. If you don't define one, Firefox always seems to generate a TBODY element as the child of the TABLE and the parent of the rows. I find the easiest workaround is to define a TBODY explicitly and work on the tbody rather than the table
2. If you leave any whitespace between the closing tag and the following
function swapNodes(item1,item2) {
// We need a clone of the node we want to swap
var itemtmp = item1.cloneNode(1);
// We also need the parentNodes of the items we are going to swap.
var parent = item1.parentNode;
var parent2 = item2.parentNode;
// First replace the second node with the copy of the first node
// which returns a the new node
item2 = parent2.replaceChild(itemtmp,item2);
//Then we need to replace the first node with the new second node
parent.replaceChild(item2,item1);
// And finally replace the first item with it's copy so that we
// still use the old nodes but in the new order. This is the reason
// we don't need to update our Behaviours since we still have
// the same nodes.
parent2.replaceChild(item1,itemtmp);
// Free up some memory, we don't want unused nodes in our document.
itemtmp = null;
}
function SwapNode(oParent, ChildNumber)
{
var oRemoved = oParent.removeChild(oParent.childNodes[ChildNumber - 1]);
oParent.insertBefore(oRemoved, oParent.childNodes[ChildNumber]);
}
That function will only work if the nodes you are trying to swap are next to each other. I suggest using one of the other versions, because this will not always be the case.
Also, in IE would it be more efficient (system resource - wise) to use swapNode? or should I stick with this for both IE and FF
In IE though I would stick to the native swapNode method, it's probably faster also.