execCommand was originally IE only and may not be available in other browsers.
As mentioned in a previous post, your code that uses getElementById should not run until after the page has loaded and the elements are available to be referred to.
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity
." Me Myself & Irene
Validate your HTML