Getting link URLs from WebView

Discussion in 'Mac Programming' started by Thethuthinang, Jan 13, 2011.

  1. Thethuthinang macrumors member

    Joined:
    Jan 3, 2011
    #1
    Hi,
    Is there an easy way to get the URLs to links shown in a WebView? I would like to get them as a list so I could choose one at random. And, I would also like to know if I could get the URL to a link my mouse is hovering over.
    Thanks in advance for any help!
     
  2. kainjow, Jan 13, 2011
    Last edited: Jan 14, 2011

    kainjow Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #2
    You can walk/search the DOM tree and look for anchor elements and grab their href attributes. Look at the DOMDocument method.

    This delegate method may help:
    webView:mouseDidMoveOverElement:modifierFlags:
     
  3. Thethuthinang thread starter macrumors member

    Joined:
    Jan 3, 2011
  4. Thethuthinang thread starter macrumors member

    Joined:
    Jan 3, 2011
    #4
    I began this thread not knowing what a DOMDocument was. After researching this, I am led to believe that there is not much documentation on this (?). I started looking the header files in the WebKit framework. I think that the DOMTreeView example included with XCode may also be a good resource. Does anyone have anything to add to this?
     

Share This Page