Java Generated Hrefs

View: New views
3 Messages — Rating Filter:   Alert me  

Java Generated Hrefs

by jason franklin-stokes :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Dear Groupies,

Situations:

I have a lot of cases where the href of a link is something like this:

<a href="javascript:void(0)">hello</a>

The href will be generated by some javascript when the element is  
clicked and the browser sent to the destination of the href.

Complication:

I need to check the real addresses of the hrefs without actually  
having to sent the browser to that address.

Question:

Is there anyway of getting the real address for the href without  
actually having to fire an event on it or send the bowser to that  
address.

Any ideas would be very much appreciated.

Thanks

Jason.

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Htmlunit-user mailing list
Htmlunit-user@...
https://lists.sourceforge.net/lists/listinfo/htmlunit-user

Re: Java Generated Hrefs

by Marc Guillemot :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Jason,

I'm not sure to understand your use case but what about following:
- you configure your own WebConnection on the WebClient (for instance
extending FalsifyingWebConnection)
- when you click a link, your WebConnection stores the requested URL and
throws an exception
- you catch this exception in your code and dismiss it but you can read
the URL from your web connection.

Cheers,
Marc.

jason franklin-stokes a écrit :

> Dear Groupies,
>
> Situations:
>
> I have a lot of cases where the href of a link is something like this:
>
> <a href="javascript:void(0)">hello</a>
>
> The href will be generated by some javascript when the element is  
> clicked and the browser sent to the destination of the href.
>
> Complication:
>
> I need to check the real addresses of the hrefs without actually  
> having to sent the browser to that address.
>
> Question:
>
> Is there anyway of getting the real address for the href without  
> actually having to fire an event on it or send the bowser to that  
> address.
>
> Any ideas would be very much appreciated.
>
> Thanks
>
> Jason.
>


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Htmlunit-user mailing list
Htmlunit-user@...
https://lists.sourceforge.net/lists/listinfo/htmlunit-user

Re: Java Generated Hrefs

by Harps :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Jason,

Pretty sure you can get the HtmlLink from the Dom and then execute the following

link.getWebResponse(true)

It shouldn't affect your current state.

So it would be something like

page.getDocumentElement()

Then hunt through the Dom to get the node representing your link

then link.getWebResponse(true).getContentAsString()



jason franklin-stokes wrote:
Dear Groupies,

Situations:

I have a lot of cases where the href of a link is something like this:

hello

The href will be generated by some javascript when the element is  
clicked and the browser sent to the destination of the href.

Complication:

I need to check the real addresses of the hrefs without actually  
having to sent the browser to that address.

Question:

Is there anyway of getting the real address for the href without  
actually having to fire an event on it or send the bowser to that  
address.

Any ideas would be very much appreciated.

Thanks

Jason.

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Htmlunit-user mailing list
Htmlunit-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/htmlunit-user