Search code examples
javascriptjqueryinternet-explorer-8wysihtml5

WYSIHTML5 character counter for IE8


I have implemented a character counter for the wysihtml5 editor in my site but it does not work in IE8. I get an error on the following line of code which I use to get the current character count from the WYSIWYG editor.

return document.getElementsByClassName('wysihtml5-sandbox')[0].contentWindow.document.body.innerText.length;

This works in FF and Chrome, but IE8 shows the following error:

Is there any way to get this to work in IE8?


Solution

  • $('.wysihtml5-sandbox')[0].contentWindow.document.body.innerText.length;
    

    I tried this and it works. I feel stupid now.