Browser compatibility for wysiwyg expansion

From #4939.

Tested working in FF and IE8.