Add clearContents() method to editbox.
Set 0 to sel.getRangeAt() function. Without this argument, only chrome and safari work properly. IE, FF don't work without this argument.
script error occurs in IE when using document.execCommand("styleWithCSS"…). Surround it with try~catch to avoid this problem.