Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Thethuthinang

macrumors member
Original poster
Jan 3, 2011
39
0
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!
 
Is there an easy way to get the URLs to links shown in a WebView?
You can walk/search the DOM tree and look for anchor elements and grab their href attributes. Look at the DOMDocument method.

And, I would also like to know if I could get the URL to a link my mouse is hovering over.
This delegate method may help:
webView:mouseDidMoveOverElement:modifierFlags:
 
Last edited:
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?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.