I am new in javascript. How to read the current url and then read the contents of the current page. Eventually, I want to count the frequency of words in the current web page.

var currentPageUrl = "";
if (typeof this.href === "undefined") {
currentPageUrl = document.location.toString().toLowerCase();

else {
currentPageUrl = this.href.toString().toLowerCase();


I used the above code to get the current page URL. So what is the next step? By the way, when I ran this script using eclipse, it just shows nothing on the page with the local browser url. How can I read (e.g www.wiki.com) page and count the frequency of words of that page. Any idea! Help, please!