• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
10
Question by Vagonn · Jan 26, 2016 at 06:23 PM · webglbrowserurltab

WebGL - Open URL in new tab?

How to open URL in new tab for WebGL?

Tried Application.OpenURL(). But it's opens a tab in same window

Thanks

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

10 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by avi9111 · Jul 25, 2017 at 12:42 PM

I think, if you are a js writer, you should would write the code like these.....

Application.ExternalEval("window.open('http://www.unity3d.com')");

I have to say the buddy on top write these first...........

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by GilesDMiddleton · Apr 22, 2017 at 05:56 PM

dppc was nearly right. The actual answer to open in a new window is to call with a 2nd parameter, replacing _blank with the name of the window you want to repeatedly target (or keep it as _blank for a new window each time).

 Application.ExternalEval("window.open(\"http://www.unity3d.com\",\"_blank\")");

However, you'll need to call something different if you want to open a URL when not in WebGL. Also, if you're trying to open social links things get more complicated, as you might want to call the native version.

     public void OpenTwitter()
     {
         if( Application.platform==RuntimePlatform.WebGLPlayer )
         {
             Application.ExternalEval("window.open(\"https://www.twitter.com/GilesDMiddleton\",\"_blank\")");
             return;
         }
         float startTime = Time.timeSinceLevelLoad;
 
         //open the twitter  app
         Application.OpenURL( "twitter:///user?screen_name=GilesDMiddleton" );
 
         if (Time.timeSinceLevelLoad - startTime <= 1f)
         {
             // typically a user takes a second to open twitter and decide what to do
             // so if the function took less than a second, it's likely it failed
             // try using normal URL opening
             Application.OpenURL( "https://www.twitter.com/GilesDMiddleton" );
         }
     }
Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by danielesuppo · Nov 04, 2016 at 08:18 PM

Yeah, but it does not work on Android devices with Chrome, so it's quite unuseable..

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image forerun · Jun 11, 2020 at 09:36 AM 0
Share

@danielesuppo the method at http://va.lent.in/opening-links-in-a-unity-webgl-project/ does work on mobile too you just have to add ontouchend to your jslib file... should look like this...

 var OpenWindowPlugin = {
     openWindow: function(link)
     {
         var url = Pointer_stringify(link);
         document.onmouseup = function()
         {
             window.open("YOUR.URL.CO$$anonymous$$");
             document.onmouseup = null;
         }
         var url = Pointer_stringify(link);
         document.ontouchend = function()
         {
             window.open("YOUR.URL.CO$$anonymous$$");
             document.ontouchend = null;
         }
     }
 };
 
 mergeInto(Library$$anonymous$$anager.library, OpenWindowPlugin);

just replace "YOUR.URL.CO$$anonymous$$" with the url you want to access...

Always a pleasure!

avatar image
10

Answer by dppc · Jan 27, 2016 at 05:48 AM

Like this:

 Application.ExternalEval("window.open(\"http://www.unity3d.com\")");

See http://docs.unity3d.com/ScriptReference/Application.ExternalEval.html for more info.

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image alexandr-melekhin · Jun 21, 2017 at 02:10 PM 3
Share

Be aware. Open link in new tab is blocked by chrome.

avatar image d2clon · Feb 26, 2021 at 08:42 AM 0
Share

Application.ExternalEval is deprecated check my answer: http://answers.unity.com/answers/1817839/view.html

avatar image
7

Answer by Teadaddy · Jan 26, 2016 at 11:06 PM

this has been needed for some time apparently, I am looking for some sort of workaround as well - please vote for this topic to be addressed by Unity, now that webGL is working, this needs to be implemented.

http://answers.unity3d.com/questions/32531/applicationopenurl-on-webplayer-to-open-in-a-new-t.html

Here is the correct answer to this question, posted beneath by Vagonn

http://va.lent.in/opening-links-in-a-unity-webgl-project/

Thanks! works like a charm

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
  • ‹
  • 1
  • 2

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

50 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Unity WebGL switch to already opened tab 1 Answer

load URL images in Webgl. 1 Answer

Game pauses when user changes browser tab (even with RunInBackground) 1 Answer

Problems using Korean domain URL 0 Answers

How to read URL parameters from Unity WebGL Build 4 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges