-1

A website would not be the same number of words in each post. Is it possible we could rank them based on the number of words or characters with JavaScript or jQuery?

Eg create links in the text length

0-200 words
201- 400 words
401-600 words

  etc

Update:

I use a hosting blogger.

Well, I will clarify my question.

I hope I can make a link that leads to a specific post by the large number of text.

For example: I have a page page1.html (has 150 words)

I hope I can make a link that leads to the post and sorted by category.

This category is based on word frequency. If the visitor clicks the link category 0-200 words, it will display the number of posts that are less than 200 words, including page1.html

I wish this could explain my question. Thank you

Norax
  • 111
  • 7

1 Answers1

1

It's hard to give a full answer as we can't see the pages where you'd get your word counts from, but...

        <body>

            <p>abc def</p>
            <p>def ghi</p>

        </body>

Really you would probably be using something like php to loop through a list of pages and then at the end you will have three arrays, each containing a list of pages with 0-200, 201-400, and 400+ words.

Then you can include a list of links to each.

        <script>
            function wordCount(){

                    var e = document.getElementsByTagName('p');

                    var totalWords = 0;
                    for (var i = 0; i < e.length; i++) {

                        var innerTx = e[i].innerHTML;
                        var wordArray = innerTx.split(' ');
                        var thisTotal = wordArray.length;
                        // alert(wordArray.length);
                        totalWords += thisTotal;
                        // totalWords += wordArray.length; 
                    //Do something
                    }//f

                    // var a = 'abc def ghi';
                    // document.write(b.length);


                    // alert(totalWords);
                    if (totalWords > 400 ) {
                        alert('400+');
                    } else if(totalWords > 200){
                        alert('200+');
                    } else {
                        alert('< 200');
                    }

                    alert('Now you need to use this information to add the specific page to an array of pages with the different word counts');
            }

            wordCount();
        </script>
Hektor
  • 1,845
  • 15
  • 19