Welcome Guest Search | Active Topics | Sign In | Register

eo:Editor and character count in FireFox Options
Mark Rae
Posted: Thursday, September 27, 2012 6:31:29 AM
Rank: Advanced Member
Groups: Member

Joined: 11/13/2008
Posts: 43
Hi,

I'm using the following to display a count of the number of characters in an eo:Editor control:

Code: HTML/ASPX
<eo:Editor runat="server" ID="Q1" Width="500px" Height="100px" FooterVisible="False" HighlightColor="255, 255, 192" ToolBarSet="Custom" Font-Bold="False" Font-Italic="False" Font-Overline="False" Font-Strikeout="False" Font-Underline="False" LineBreakMode="Br" ClientSideOnChange="charCount" FontNames="Arial" PasteFilter="TextWithLineBreak">


Code: JavaScript
function charCount(ed, count)
{
	document.getElementById(count).innerText = jQuery.trim(eo_GetObject(ed).getText()).length;
}


This works perfectly in every browser except FireFox. Is this a known issue with FireFox? If so, is there a way round it?

Alternatively, is there a better way of displaying a real-time character count of an eo:Editor?

Thanks,

Mark
eo_support
Posted: Thursday, September 27, 2012 1:00:37 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,195
Hi,

Your way is correct. But FireFox doesn't support innerText. So you have to use innerHTML instead.

Thanks!
Mark Rae
Posted: Thursday, September 27, 2012 2:34:22 PM
Rank: Advanced Member
Groups: Member

Joined: 11/13/2008
Posts: 43
Simple as that, eh? :-)

Thanks.
Mark Rae
Posted: Friday, September 28, 2012 6:05:37 AM
Rank: Advanced Member
Groups: Member

Joined: 11/13/2008
Posts: 43
Actually, I found a different and better way which doesn't involve innerText / innerHtml and seems to be completely browser independent:

Code: JavaScript
function charCount(ed, count)
{
	var chrCount = document.getElementById(count);
	while (chrCount.firstChild !== null) {chrCount.removeChild(chrCount.firstChild); }
	chrCount.appendChild(document.createTextNode(jQuery.trim(eo_GetObject(ed).getText()).length));
}


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.