How to get URL params in Html Godot game

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

Hi,

I load a game in Url with params (like: game.com/game1.php?id=23).

How I can get the Url string or only params in GDScript?

Not is posible? I really need this :frowning:

Phyron | 2020-04-17 16:21

:bust_in_silhouette: Reply From: eggman

Hi,

I’m resolve this problem with javascripts

func get_parameter(parameter):
if OS.has_feature('JavaScript'):
	return JavaScript.eval(""" 
			var url_string = window.location.href;
			var url = new URL(url_string);
			url.searchParams.get(parameter);
		""")
return null

Hope this can help you

Very usefull for me. Thanks!

jack_pluskota | 2021-10-16 00:37