View Single Post
Old 01-19-2013, 07:43 PM   PM User | #8
elitis
Regular Coder

 
Join Date: Sep 2010
Posts: 319
Thanks: 9
Thanked 6 Times in 6 Posts
elitis is an unknown quantity at this point
Quote:
Originally Posted by AndrewGSW View Post
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);}
__________________
Coding is a challenge, get used to it
Always remember to debug
Try the guess & check method
Break it down into simple steps
elitis is offline   Reply With Quote