How to open links from html5 bundle

I have a more games button and I need open my web site when click in the button, how can open a url in a new tab? (html5 game)

Maxi.

Hi @qkygames!
You should be able to use html.run() to run the relevant JavaScript code you need.

1 Like

work, but Chrome block site, how can open a new tab without blocking?

Nowadays, the browsers are very restrictive regarding when and how the user experience is handled. For instance, fullscreen mode must be preceded by a user input action. I believe this is also the case with popups windows (or new tabs). Are you opening the tab as the result of a mouse click?

yes, this is my code in on_input

if gui.pick_node(self.btnMoreGames, action.x, action.y) then
			
			msg.post("main:/music_manager#music_manager", "playfx", {fx = "#sndClick"})

			local code = "window.open('www.google.com','_blank')"
			html5.run(code )
end

I’ve just tried this myself and it’s the same for me. Frankly, I currently don’t know how to solve that issue. Perhaps @britzl or @sven has some ideas?

I found a solution, maybe a little strange.

I have this in my on_input() pressed

if action.pressed then
		if gui.pick_node(self.btnMoreGames, action.x, action.y) then
			gui.play_flipbook(self.btnMoreGames,"btnMoreGames0002")
			html5.run("pressed()")
		end
end

and this in my custom index:

<script>
		function pressed()
		{
			document.getElementById("canvas").onclick = function (e) {
	      		openqkygames()
	   		 };
		}
	   function openqkygames()
	   {
	   		window.open("http://www.qkygames.com",'_blank');
	   		document.getElementById("canvas").onclick = "";
	   }
	</script>

so when pressed the button more games, I call “pressed” to created a click release event for canvas in index and when is called I remove it.

sorry for my english.

7 Likes