Re: Can I get document.links in JavaXPCOM ?

Carfield Yim <[email protected]>
Newsgroups gmane.comp.mozilla.devel.oji
Organization http://groups.google.com
Message-ID <[email protected]>
HI, is that I cannot get absolute URLs using  htmlDoc.getLinks()? I've
tried to use the following code but I can still just get the relative
URLs, why will that happened?

On 6 22 ,   12 30 , Carfield Yim <[email protected]> wrote:
> On 6 17 ,   11 33 , Michal Ceresna <[email protected]> wrote:
>
> > On Sunday 17 June 2007, Carfield Yim wrote:
> > Hello,
>
> > > Can I get the list of links with document.links in JavaXPCOM?
>
> > sure,
>
> > nsIDOMDocument doc = ...;
> > nsIDOMHTMLDocument htmlDoc = (nsIDOMHTMLDocument) doc.queryInterface(nsIDOMHTMLDocument.NS_IDOMHTMLDOCUMENT_IID);
> > nsIDOMHTMLCollection links = htmlDoc.getLinks();
>
> > best regards,
> > Michal
>
> Thanks , now I can get document.links and link.href. However, it is
> just relative links like what I get from getElementByTagName("a") .
> Can I get absolute links?
>
> More specific, I run the following code:
>
>                                                         final
> nsIDOMHTMLDocument htmlDoc = (nsIDOMHTMLDocument)
> doc.queryInterface(nsIDOMHTMLDocument.NS_IDOMHTMLDOCUMENT_IID);
>                                                         final
> nsIDOMHTMLCollection list = htmlDoc.getLinks();
>                                                         final
> List<String> links = new ArrayList<String>();
>                                                         for (int i =
> 0; i < list.getLength(); i++) {
>                                                                 final
> String nodeValue = list.item(i).getAttributes()
>                                                                                 .getNamedItem("href").getNodeValue();
>
> links.add(nodeValue);
>
> System.out.println(nodeValue);
>                                                         }
>
> What I get is
>
> archiver/
> archiver/?fid-9.html
> archiver/?tid-305790.html
> archiver/?tid-364135.html
>
> but what I need is
>
> http://www.xxx.net/archiver/http://www.xxx.net/archiver/?fid-9.htmlhttp://www.xxx.net/archiver/?tid-305790.htmlhttp://www.xxx.net/archiver/?tid-364135.html
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.