Re: Javascript - How can I retrive the Character count?

  •  10-22-2009, 4:41 PM

    Re: Javascript - How can I retrive the Character count?

    Back to my solo conversation I figured out another way to do it...
     
    function getCount() {
    var cnt = getElementsByClass('CharCount',document.getElementById("CE_Editor1_ID"),"span");
    cnt = (cnt[0].innerHTML.replace("Characters:","")*1)
    alert(cnt+100);
    }

    function getElementsByClass(searchClass,node,tag) {
            var classElements = new Array();
            if ( node == null )
                    node = document;
            if ( tag == null )
                    tag = '*';
            var els = node.getElementsByTagName(tag);
            var elsLen = els.length;
            var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
            for (i = 0, j = 0; i < elsLen; i++) {
           if ( pattern.test(els[i].className) ) {
               classElements[j] = els[i];
               j++;
           }
            }
            return classElements;
    }
     
View Complete Thread