vendredi 24 novembre 2017

Unity WebGL on Kongregate: Open in-game link in a new tab

I've recently presented my first game on Kongregate. Unfortunately, I'm having problems with the in-game links that should open external pages (like Facebook, Twitter) in new tabs. :( The problem originates in the fact that the game executes from another domain (konggames) in an iframe.

I use Unity to develop my game. The most basic way to open links is (C#):

Application.OpenURL( link );

Unfortunately, this instruction tries to open the link in the same iframe, so in the result, the game iframe goes black-blank. The very same effect occurs when I use the external Javascript call:

window.open( link, "_blank");

So I figured, hey, let's refer to the actual browser window, shall we?:

window.parent.open( link, "_blank")

...but this causes a Javasript cross-domain security exception... (due to the iframe konggames.com being embedded in kongregate.com domain) --_--

I'm currently just using

window.open( link, "_top")

which causes to replace the kongregate (game) tab with Facebook/Twitter content which is definitely NOT the greatest solution ever.

I would really appreciate Your help with this issue. Thanks in advance! :)




Aucun commentaire:

Enregistrer un commentaire