- Home /
Unity WebGL switch to already opened tab
Hi,
if I open a link via a WebGL build it opens it in a new tab every time I call it. Is there possibly a way to check if the link was already opened or if a tab with that link already exists and just switch the tabs in the browser instead of opening a new tab over and over again?
Thanks in advance!
Answer by Bunny83 · Dec 16, 2021 at 11:47 AM
if I open a link via a WebGL build
You have to be way more specific here. Do you mean you open another seperate website from inside your WebGL build? If so, how do you do that?
This all boils down to pure browser behaviour and most techniques involve javascript and is not necessarily supported in all browsers since the behaviour may depend on the user settings. However you generally can specify a "target" window where a link should be opened in. Usually when you want to open a link in a new tab, you would use the special name "_blank". Any other value will try to open the link in a window / tab with that name. If the name does not exist the browser will open a tab / windows and give it that name. So subsequent links with the same target should open in the same tab / window.
Sorry that I wasn't precise. Right now I am simply calling:
Application.OpenURL("myURL");
which automatically opens the url in a new tab.
Regarding the "target". Would I implement the script specifying the "target" inside of Unity or is this behaviour completely based in the browser / on the web server?
Your answer
Follow this Question
Related Questions
WebGL - Open URL in new tab? 10 Answers
Check URL in WebGL 1 Answer
Video Player WebGl Transparency problem - previous frames doesn't clear 1 Answer
Load image from url in Webplayer 1 Answer
WebGL - InvalidStateError: An attempt was made to use an object that is not, or is no longer, usable 1 Answer