在IE中交换两个“ onclicks”

i want to change the onclicks of two elements. In Firefox this code does what it should:

var tmpButton = button1.onclick;
button1.setAttribute('onclick', button2.onclick);
button2.setAttribute('onclick', tmpButton);

But how can i realize this code in IE ?

The following should work in both browsers:

var tmpButton = button1.onclick;
button1.onclick = button2.onclick;
button2.onclick = tmpButton;

The setAttribute method is not 100% cross-platform safe. Quirksmode says IE implementation of setAttribute is incomplete:

IE5-7 doesn't set styles and removes events when you try to set them.

Note: working example of this: http://jsfiddle.net/slebetman/RHHzc/