Sign in to follow this  
sandy234

How to open window in new tab

Recommended Posts

You cannot force that. It depends on the browser settings, if a new window is going to be opened, or a new tab will be opened.

 

But setting the target attribute of a a-tag to "_blank" should open a new tab on most browsers.

iOS browsers only have windows; no tabs for technical reasons. But its more or less the same.

Share this post


Link to post
Share on other sites
function openURL(url){var _a=document.createElement("a");_a.href=url;_a.target="_blank";var _div=document.getElementById("gm4html5_div_id");document.body.insertBefore(_a,_div);_a.click();}

 

Still doesn't force a new tab in the same window, But it doesn't detect as a pop up or get blocked , so It's a good way of doing it :)

Share this post


Link to post
Share on other sites

Apparently sponsor wants to open link in new tab

 

I did this

function myOpen() {      window.open("http://sponsor.com","_blank");    }

This does opens in new tab in desktop but its blocked as popup while it doesnt work at all on ios

Any soln for this. GMS function also doesnt open in new tab

Share this post


Link to post
Share on other sites

This is what i did copy pasted your code created an extension in GM

inside it called function

openURL("http://sponsor.com")

 

It opens in new window in chrome. Also its considered as popup

 

Well , that's very strange because it worked with me and with other people who tested it , but putting that aside , here is a new method : (note I didn't test this) 

 

 // Add this to your html page<a href="#" target="_blank" id="targetA"></a> // Add this to the javascriptfunction openUrl(url){var _a=document.getElementById("targetA");_a.href=url;_a.click();window.focus();} // Add the extension to game maker openUrl("http:sponsor.com"); 

 

Let me know if that works.

Share this post


Link to post
Share on other sites

Again doesnt work on chrome opens in a new window and not tab

whats your GMS version

 

As I said , there is nothing you can do to force opening it in a new tab.

 

What you can do is make sure your link isn't detected as a pop up , because on mobile devices there is no such thing as a new window or tab ;)

)

Share this post


Link to post
Share on other sites

Problem is sponsor wants game to open in a new tab. They already rejected game bec it opened in new window.

Also games in their portal seems to open game in new tab. Dont know why it aint working in game maker

 

It's not about game maker , and are you sure they rejected it because it opened in a new window , not in the same  tab ? 

 

It's not debatable , you really can't force opening games in a new tab , it's browser reference. And as I said to you before , new window = new tab on mobile devices :)

Share this post


Link to post
Share on other sites

yes they specified in their email that game need to open in new tab and not in new window in desktop browsers.

Its doable bec others have already done it in their games. Sponsor logo opens in new tab in their games.

Share this post


Link to post
Share on other sites

yes they specified in their email that game need to open in new tab and not in new window in desktop browsers.

Its doable bec others have already done it in their games. Sponsor logo opens in new tab in their games.

 

If you want branding that's visible everywhere in the game , like this  , You can follow these steps:

 

// add the following to the html file of the game<a href="http:/sponsor.com" target="_blank"><img id="imgBrand" src="the brand logo image.png"></img></a> //add this to the css of the game#imgBrand{position:absolute;z-index:5;}#canvas{z-index:1;}

Share this post


Link to post
Share on other sites

Just so I let you know , splash screen opens in the same tab. And in game branding doesn't detect as pop up.

 

Additionally , Yes , the position can be changed by changing absolute position of left and top values of the element or by creating an element for each position and showing/hiding them on need.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.