# Extension to interact with the web in exported games

**URL:** https://forum.makecode.com/t/extension-to-interact-with-the-web-in-exported-games/4262
**Category:** Arcade
**Tags:** extension
**Created:** [November 3, 2020, 9:31pm UTC](https://forum.makecode.com/t/extension-to-interact-with-the-web-in-exported-games/4262 "2020-11-03T21:31:36Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![peli](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/peli/32/12_2.png) [@peli](https://forum.makecode.com/u/peli)
#### Post date: [November 3, 2020, 9:31pm UTC](https://forum.makecode.com/t/extension-to-interact-with-the-web-in-exported-games/4262/1 "2020-11-03T21:31:36Z")

</div>

Let’s start with the demo: an **exported** Arcade game that opens a new browser tab.

> **[arcade-browser](https://pelikhan.github.io/arcade-browser/)**
>
> Allows to update new browser tabs with MakeCode Arcade

**In general, Arcade games are completely sandboxed…** So how can we open a new tab? Let’s take a look.

The `control.simmessages` is a new API added in Arcade to support the JACDAC simulator… but you can use it too **in GitHub Pages**.

`simmessages` allow to send or receive a data payload to the hosting iframe of the simulator (those messages are ignored on hardware). In [arcade.makecode.com](http://arcade.makecode.com), you are not allowed to inject custom javascript to handle those messages BUT… **if you export your game to GitHub, you put your custom logic** and do all kinds of cool features.

In this demo, the game calls a “open url” function

> <https://github.com/pelikhan/arcade-browser/blob/master/test.ts#L3>

That function sends a “web open url” message over `control.simmessages`.

> <https://github.com/pelikhan/arcade-browser/blob/master/main.ts#L7>

On the browser javascript side, we’ve added custom code to handle the message.

> <https://github.com/pelikhan/arcade-browser/blob/master/assets/js/loader.js#L99>

and we’ve registered a function handler for the “web” channel

> <https://github.com/pelikhan/arcade-browser/blob/master/assets/js/custom.js#L7>

So eventually, through a few layers your message from the MakeCode Arcade game routes itself to the handler that calls `window.open`.

Full sources [https://github.com/pelikhan/arcade-browser](https://github.com/pelikhan/arcade-browser)

---

<div class="post-metadata">

### Author: ![UnsignedArduino](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/unsignedarduino/32/592_2.png) [@UnsignedArduino](https://forum.makecode.com/u/UnsignedArduino)
#### Post date: [November 3, 2020, 10:16pm UTC](https://forum.makecode.com/t/extension-to-interact-with-the-web-in-exported-games/4262/2 "2020-11-03T22:16:13Z")

</div>

Nice! I can see use in like if you have a really complex game, instead of explaining it all in text boxes you can redirect them to your `README.md` in the repository.

Except, it doesn’t work for me:

 ![arcade browser](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/5/5711c99e112be815b68bbdcc8b998cedfbb7cee3.gif)

---

<div class="post-metadata">

### Author: ![peli](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/peli/32/12_2.png) [@peli](https://forum.makecode.com/u/peli)
#### Post date: [November 4, 2020, 7:19am UTC](https://forum.makecode.com/t/extension-to-interact-with-the-web-in-exported-games/4262/3 "2020-11-04T07:19:47Z")

</div>

Indeed, i broke it !

---

<div class="post-metadata">

### Author: ![peli](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/peli/32/12_2.png) [@peli](https://forum.makecode.com/u/peli)
#### Post date: [November 4, 2020, 7:23am UTC](https://forum.makecode.com/t/extension-to-interact-with-the-web-in-exported-games/4262/4 "2020-11-04T07:23:49Z")

</div>

Fixed in v.0.0.4. Thanks!

---

<div class="post-metadata">

### Author: ![UnsignedArduino](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/unsignedarduino/32/592_2.png) [@UnsignedArduino](https://forum.makecode.com/u/UnsignedArduino)
#### Post date: [November 4, 2020, 12:24pm UTC](https://forum.makecode.com/t/extension-to-interact-with-the-web-in-exported-games/4262/5 "2020-11-04T12:24:58Z")

</div>

Nice, it works!

The first 2 times, it didn’t work because Chrome considered it a “pop-up”. The third time worked. Just saying if anyone is confused.

---

<div class="post-metadata">

### Author: ![gian1922](https://avatars.discourse-cdn.com/v4/letter/g/3d9bf3/32.png) [@gian1922](https://forum.makecode.com/u/gian1922)
#### Post date: [November 22, 2021, 4:37pm UTC](https://forum.makecode.com/t/extension-to-interact-with-the-web-in-exported-games/4262/6 "2021-11-22T16:37:10Z")

</div>

Hello! Is the code still working? I have tried to implement it in my game but it opens a new simulator instead of redirecting to an URL. Could you kindly help me out? Thanks a lot!

---

<div class="post-metadata">

### Author: ![Selva](https://avatars.discourse-cdn.com/v4/letter/s/13edae/32.png) [@Selva](https://forum.makecode.com/u/Selva)
#### Post date: [April 15, 2024, 4:35pm UTC](https://forum.makecode.com/t/extension-to-interact-with-the-web-in-exported-games/4262/7 "2024-04-15T16:35:41Z")

</div>

Thanks it was help me lot,But it’s not redirect my site, Even i change code in test.ts it redirecting [https://makecode.com/](https://makecode.com/).  
,Is i am miss anything.
