Quote:
Originally Posted by AndrewGSW
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've checked it in IE9, Chrome (23 I think), and Firefox 18.01. It doesn't work in ANY of them. But like I said before it works fine in all browsers if I use an inline onclick event handler.
Updated code: (NOTE: I am not using jQuery.)
Code:
if (window.addEventListener){window.addEventListener('load',iFrameOn,false);}
else if (document.addEventListener) {
document.addEventListener('load',iFrameOn,false);
$('bold').addEventListener('click',iBold,false);
$('underLine').addEventListener('click',iUnderline,false);
$('italic').addEventListener('click',iItalic,false);
$('fontColor').addEventListener('click',iForeColor,false);
$('ul').addEventListener('click',iUnorderedList,false);
$('ol').addEventListener('click',iOrderedList,false);
$('img').addEventListener('click',iImage,false);
$('deny').addEventListener('click',denyFR,false);
$('accept').addEventListener('click',acceptFR,false);
$('sbmt').addEventListener('click',sendData,false);
}
else if (document.attachEvent){document.attachEvent('onload',iFrameOn,false);}
function $(element){document.getElementById(element);}
function iFrameOn(){richTextField.document.designMode = 'On';}
function iBold(){richTextField.document.execCommand('bold',false,null);}
function iUnderline(){richTextField.document.execCommand('underline',false,null);}