Lazarus

Programming => LCL => Topic started by: OLLI_S on February 28, 2019, 04:18:00 pm

Title: [Solved] THtmlViewer - HyperLinks are not working
Post by: OLLI_S on February 28, 2019, 04:18:00 pm
Hello,

I am using Lazarus 1.8.4 in Windows 10 Professional x64.
I know that Lazarus 2.0 is out now, just had no time to install...

On my form I have a THtmlViewer and in the HTML-File that I am displaying there is also a link:
Code: Text  [Select][+][-]
  1. <a href="https://website.com" target="_blank">https://website.com</a><br>

The link is correctly displayed as link (blue font and underlined) and when I move the mouse over the link, the mouse pointer changes to the crHand cursor.
But when I click the link then nothing happens.

What is wrong?
Here the default browser should be openen and the link should be opened in a new browser tab.
Thank you for you help!

Best regards

OLLI
Title: Re: THtmlViewer - HyperLinks are not working
Post by: Handoko on February 28, 2019, 06:54:12 pm
I checked the info here:
https://github.com/BerndGabriel/HtmlViewer

It does not said it has the ability to get data directly from the web. I could be wrong but I think it is only a html viewer, not a web browser.

If you want to manually load the web data (and then supply the data to the THtmlViewer), you can use TFPHTTPClient:
http://wiki.lazarus.freepascal.org/fphttpclient

If you want to  detect the default web browser and open an URL using it, you can try OpenURL:
http://wiki.lazarus.freepascal.org/Webbrowser#OpenURL

If you want a web browser, maybe these are what you're looking for:
http://wiki.lazarus.freepascal.org/fpbrowser
http://wiki.freepascal.org/fpCEF3
Title: Re: THtmlViewer - HyperLinks are not working
Post by: OLLI_S on February 28, 2019, 08:32:39 pm
Hello,

I am using the THtmlViewer to display the Change-Log of my application and the Help for my application.
So this is static text, nothing dynamic.

I one passage I have a link to a forum where users can give feedback.
So it would be cool if users are able to click the link, then the URL is opened in the default browser.
The strange thing is that the link is displayed blue and underlined and is also clickable.
But if I click it then nothing happens.

Best regards

OLLI
Title: Re: THtmlViewer - HyperLinks are not working
Post by: lucamar on March 01, 2019, 10:12:44 am
Add a handler for the OnHotSpotClick event and launch the browser there, for example with OpenURL()
Title: Re: THtmlViewer - HyperLinks are not working
Post by: OLLI_S on March 01, 2019, 11:34:59 am
Add a handler for the OnHotSpotClick event and launch the browser there, for example with OpenURL()

Thank you, it worked!
Did not know that there is a special OnHotSpotClick event for that.
Issue is solved!
Title: Re: THtmlViewer - HyperLinks are not working
Post by: lucamar on March 01, 2019, 11:49:58 am
Did not know that there is a special OnHotSpotClick event for that.

Neither did I, though it was a strong posibility so I just downloaded the latest THtmlViewer, dived into the documentation and checked with the source. Easy. :)
Title: Re: [Solved] THtmlViewer - HyperLinks are not working
Post by: OLLI_S on March 01, 2019, 11:52:18 am
Shaming for me... %)
TinyPortal © 2005-2018