www.webdeveloper.com
Results 1 to 2 of 2

Thread: Javascript : How to read web page content

  1. #1
    Join Date
    Feb 2014
    Posts
    1

    Unhappy Javascript : How to read web page content

    Hi,
    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!

    Thanks,
    Kitty

  2. #2
    Join Date
    Mar 2009
    Posts
    467
    If you're talking about about using javascript to download a page from any site and then manipulating the content the short answer is that you can't really do this from a browser. The page itself would have to contain the code needed to do this. You can't inject the script into a page fetched from a foreign domain that you do not control. Browser powered Javascript is not going to help you, although you could do this with node.js fairly simply, but that doesn't run from the browser.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles