I have an issue with some Javascript code which changes square brackets to curly brackets in a html textarea. It works fine in Firefox but not IE8.

When typing the text in it changes the brackets as expected and if you use the back key to delete text it works fine but if you have say 4 lines of text and highlight the last 2 lines and hit the delete key it deletes everything.


I think the problem is related to the scrolltop references in the removeBadCharacters function. Any help would be appreciated.

If I have attached a fiddle with the code:

http://jsfiddle.net/hrHzc/20/