Recent

Author Topic: [Solved] THtmlViewer - HyperLinks are not working  (Read 1291 times)

OLLI_S

  • Full Member
  • ***
  • Posts: 111
[Solved] THtmlViewer - HyperLinks are not working
« 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
« Last Edit: March 01, 2019, 11:35:46 am by OLLI_S »

Handoko

  • Hero Member
  • *****
  • Posts: 3128
  • My goal: build my own game engine using Lazarus
Re: THtmlViewer - HyperLinks are not working
« Reply #1 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

OLLI_S

  • Full Member
  • ***
  • Posts: 111
Re: THtmlViewer - HyperLinks are not working
« Reply #2 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

lucamar

  • Hero Member
  • *****
  • Posts: 1986
Re: THtmlViewer - HyperLinks are not working
« Reply #3 on: March 01, 2019, 10:12:44 am »
Add a handler for the OnHotSpotClick event and launch the browser there, for example with OpenURL()
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus 2.0.2/2.0.4  - FPC 3.0.4 on:
(K|L)Ubuntu 12..16, Windows XP SP3, various DOSes.

OLLI_S

  • Full Member
  • ***
  • Posts: 111
Re: THtmlViewer - HyperLinks are not working
« Reply #4 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!

lucamar

  • Hero Member
  • *****
  • Posts: 1986
Re: THtmlViewer - HyperLinks are not working
« Reply #5 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. :)
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus 2.0.2/2.0.4  - FPC 3.0.4 on:
(K|L)Ubuntu 12..16, Windows XP SP3, various DOSes.

OLLI_S

  • Full Member
  • ***
  • Posts: 111
Re: [Solved] THtmlViewer - HyperLinks are not working
« Reply #6 on: March 01, 2019, 11:52:18 am »
Shaming for me... %)