HotAir,
Change your code to:
<script language="javascript">
// get the cute editor instance
var editor1 = document.getElementById('<%=RemarksEditor.ClientID%>');
function CE_attachEvent()
{
// get the cute editor instance
if(editor1.attachEvent)
editor1.attachEvent('onclick',CountWords);
else if(editdoc.addEventListener)
editor1.addEventListener('onclick',CountWords,true);
//Get the editor content
var editdoc=editor1.GetDocument();
// attach Event
if(editdoc.attachEvent)
editdoc.attachEvent('onkeypress',CountWords);
else if(editdoc.addEventListener)
editdoc.addEventListener('keypress',CountWords,true);
CountWords();
}
function CE_detachEvent()
{
// get the cute editor instance
//var editor1 = document.getElementById('<%=RemarksEditor.ClientID%>');
//Get the editor content
var editdoc=editor1.GetDocument();
// detach Event
if(editdoc.detachEvent)
editdoc.detachEvent('onkeypress',CountWords);
else if(editdoc.removeEventListener)
editdoc.removeEventListener('keypress',CountWords,true);
}
//as page loads, attach it:
//tried to do this with Page.RegisterStartupScript, but it also, only sometimes works
//with this inline version, it works 1 of 8 times.
CE_attachEvent();
setTimeout(CE_attachEvent,1000);
function CountWords()
{
// get the cute editor instance
document.getElementById('RemarksEditorCount').innerHTML = 'Character Count = ' + editor1.getHTML().length;
}
</script>
asp.net Chat http://cutesoft.net/ASP.NET+Chat/default.aspx
Web Messenger: http://cutesoft.net/Web-Messenger/default.aspx
asp.net wysiwyg editor: http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx
asp wysiwyg html editor: http://cutesoft.net/ASP
asp.net Image Gallery: http://cutesoft.net/ASP.NET+Image+Gallery/default.aspx
Live Support: http://cutesoft.net/live-support/default.aspx