# How to open links from html5 bundle

**URL:** <https://forum.defold.com/t/how-to-open-links-from-html5-bundle/9181>\
**Category:** Questions\
**Created:** [June 15, 2017, 2:23pm UTC](https://forum.defold.com/t/how-to-open-links-from-html5-bundle/9181 "2017-06-15T14:23:50Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![qkygames](https://forum-defold.b-cdn.net/letter_avatar_proxy/v4/letter/q/6de8d8/32.png) [@qkygames](https://forum.defold.com/u/qkygames)\
**Post date:** [June 15, 2017, 2:23pm UTC](https://forum.defold.com/t/how-to-open-links-from-html5-bundle/9181/1 "2017-06-15T14:23:50Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Mathias\_Westerdahl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/mathias_westerdahl/32/228_2.png) [@Mathias\_Westerdahl](https://forum.defold.com/u/Mathias_Westerdahl)\
**Post date:** [June 15, 2017, 2:26pm UTC](https://forum.defold.com/t/how-to-open-links-from-html5-bundle/9181/2 "2017-06-15T14:26:30Z")

</div>

Hi @qkygames!  
You should be able to use [html.run()](https://www.defold.com/ref/html5/#html5.run:code) to run the relevant JavaScript code you need.

---

<div class="post-metadata">

**Author:** ![qkygames](https://forum-defold.b-cdn.net/letter_avatar_proxy/v4/letter/q/6de8d8/32.png) [@qkygames](https://forum.defold.com/u/qkygames)\
**Post date:** [June 15, 2017, 2:31pm UTC](https://forum.defold.com/t/how-to-open-links-from-html5-bundle/9181/3 "2017-06-15T14:31:25Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Mathias\_Westerdahl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/mathias_westerdahl/32/228_2.png) [@Mathias\_Westerdahl](https://forum.defold.com/u/Mathias_Westerdahl)\
**Post date:** [June 15, 2017, 2:55pm UTC](https://forum.defold.com/t/how-to-open-links-from-html5-bundle/9181/4 "2017-06-15T14:55:47Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![qkygames](https://forum-defold.b-cdn.net/letter_avatar_proxy/v4/letter/q/6de8d8/32.png) [@qkygames](https://forum.defold.com/u/qkygames)\
**Post date:** [June 15, 2017, 2:57pm UTC](https://forum.defold.com/t/how-to-open-links-from-html5-bundle/9181/5 "2017-06-15T14:57:06Z")

</div>

yes, this is my code in on\_input

```lua
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

```

---

<div class="post-metadata">

**Author:** ![Mathias\_Westerdahl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/mathias_westerdahl/32/228_2.png) [@Mathias\_Westerdahl](https://forum.defold.com/u/Mathias_Westerdahl)\
**Post date:** [June 15, 2017, 3:55pm UTC](https://forum.defold.com/t/how-to-open-links-from-html5-bundle/9181/6 "2017-06-15T15:55:19Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![qkygames](https://forum-defold.b-cdn.net/letter_avatar_proxy/v4/letter/q/6de8d8/32.png) [@qkygames](https://forum.defold.com/u/qkygames)\
**Post date:** [June 15, 2017, 5:25pm UTC](https://forum.defold.com/t/how-to-open-links-from-html5-bundle/9181/7 "2017-06-15T17:25:44Z")

</div>

I found a solution, maybe a little strange.

I have this in my on\_input() pressed

```lua
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:

```lua
<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.
