I bet this answer will help you.
I was thinking of a similar approach to the one presented here. Basically, you will have to do something like this:
It basically copies the whole text from inside the textarea into a div of the same size. I have set some CSS to ensure that in every browser, the textarea and the div wrap their content in exactly the same way.