+1 vote

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: Sample

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!

Godot version 3.4
in Engine by (13 points)

1 Answer

0 votes

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: https://godotengine.org/qa/46978/how-do-i-open-richtextlabel-bbcode-links-in-an-html5-export

"Basically, if it's HTML let the browser handle the call (by doing nothing). If it's not HTML, hook up the metaclick signal manually in the _ready function for any OS and make the OS call the url using the shellopen function." - ElectronicArmory

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

by (33 points)
edited by
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.