How to get links to work when exporting to Web (HTML5)?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By MarsDHe

Hi, I’m working on an educational game with links to further readings. I’m using [url] tags in RichTextLabels, and using the following code:

 func _on_Text_meta_clicked(meta):

This code works when running on Desktop, but not when it’s running in browser. When it runs in browser, clicking the link brings me to this page:

It seems that the OS.shell_open() command doesn’t open the link as a link, and instead tries to open it in a different format, but I’m not sure what exactly is going on or how to fix it. Would greatly appreciate any help. Thanks!

:bust_in_silhouette: Reply From: Cyanic Cipher

From what I understand you shouldn’t need (or want to) to run an OS.shell_open() command while in HTML5, as the browser should recognize the link natively. So the solution is to not run the command or not connect the signal while it’s running in HTML5.

Here’s the answer to the same question that helped me: How do I open RichTextLabel BBCode links in an HTML5 export? - Archive - Godot Forum

“Basically, if it’s HTML let the browser handle the call (by doing nothing). If it’s not HTML, hook up the meta_click signal manually in the _ready function for any OS and make the OS call the url using the shell_open function.” - ElectronicArmory

I also needed to insure the proper https:// prefix for links to work.