I want to catch and consume (prevent redirection) link events on the teamdev's jxbrowser. Suppose the content is
<a href="testlink">link</a>
When the user clicks the link, I want to be informed that the user has clicked the link and get the URL, but I do not allow the page change (link should be consumed).
The problem is, the links in the quotes of the anchor tag do not start with any protocol (http:// or https:// and do not end with any .html or etc). For example the link is in the form of:
<a href="foo">link<a>
and we want when user clicks on the link, we get informed that the clicked string is foo. I know, the links in this a tag are not valid and not well formed due to the standarts, but the contents are generated by using some specific busines rules and then set to the JxBrowser. And we can not change the way the links are created.
With the example below, we get about:blank for the url, which is not the desired info. If we change to
<a href="http://foo">link</a>
then it works fine but we can not modify the links (content) as I have mentioned before.
browser.addLoadListener(new LoadListener () {
public void onStartLoadingFrame(StartLoadingEvent arg0) {
System.out.println("link click occured " + arg0.getValidatedURL());
arg0.getBrowser().stop();
}
);