Webview to load only text from a page?


Last Updated:

  1. ajent

    ajent Member This Topic's Starter

    Joined:
    Jun 3, 2010
    Messages:
    7
    Likes Received:
    0
    There's a site i'd like to put into webview, however I want to remove 1 image that's listed at the bottom, and the links.

    Basically I want the webview to load the page, without the <a href=> and <img src=> tags.

    Is this possible?

    Thanks
     

    Advertisement
  2. ajent

    ajent Member This Topic's Starter

    Joined:
    Jun 3, 2010
    Messages:
    7
    Likes Received:
    0
    Here's another idea, this url: lexanderA Extracting HTML from a WebView
    Has information on pulling html code out of the webview, so my idea is, can I have the html code pulled out of the webview, then only the part I want be displayed to the user?
    no tags, just the text in the middle that is generated.

    Thanks
     
  3. ajent

    ajent Member This Topic's Starter

    Joined:
    Jun 3, 2010
    Messages:
    7
    Likes Received:
    0
    I got it!
    By injecting javascript I had to use
    Code (Text):
    1. webview.loadUrl("javascript:(function() { " +
    2.                     "document.getElementsByTagName('a')[0].style.display = 'none'; " +
    3.                     "})()");
    That removes the link (<a href> code). Replacing ('a') with ('img') would remove the images.

    (thanks lexanderA Injecting JavaScript into a WebView )
     

Share This Page

Loading...