How do I open new url without get blocked by the browser

Get help using Construct 2

Post » Thu Oct 27, 2016 9:59 am

Using the HTML5 version if i open an url in the same page no problems.

But with "Open URL in new window" the browser(Firefox) catch it and deny the action(With some yellow alert saying that "this page tried to open a new window and firefox blocked it" , ( on Chrome/Opera works.).

I tried to upload my game in some site, and the other games in the site opens a url in a new window without problem, but from mine it's blocked.

So, is there anyway in C2 to add some event or something to do it correctly or some way to fix that?
B
23
S
10
G
3
Posts: 542
Reputation: 4,434

Post » Fri Oct 28, 2016 2:35 pm

You can't. Those are anti-spam devices integrated into browsers to prevent annoying advertisement developers from doing exactly what you are trying to do.
https://www.ravenheart.ca/home
Company name changed to avoid Facebook-type shenanigans

"Someone once told me I bite off more than I can chew...

I told them I would rather choke on greatness than nibble on mediocrity."
B
22
S
6
G
1
Posts: 1,414
Reputation: 4,822

Post » Fri Oct 28, 2016 3:02 pm

And why from flash and other games in the same site the external links in a new windows are allowed without problems but the same thing from my game are blocked?
B
23
S
10
G
3
Posts: 542
Reputation: 4,434

Post » Fri Oct 28, 2016 6:02 pm

Last time I checked (a whiiiile ago) if the condition was directly an ->on clicked event it worked, if wrapped in a function, it blocked it.

So my guess is that the open url in a new window has to be a user input response. Could be wrong though.
Game design is all about decomposing the core of your game so it becomes simple instructions.
B
52
S
22
G
18
Posts: 2,122
Reputation: 17,093

Post » Fri Oct 28, 2016 6:06 pm

Mines are: On clickd on a object > Browser Go to X url in a new window with "New Window" tag.
B
23
S
10
G
3
Posts: 542
Reputation: 4,434

Post » Fri Oct 28, 2016 6:15 pm

just tried it, it does not do it with the button object >on clicked condition, maybe by having an invisible button over your object you can trick it, will do some tests if I have time...

edit: nevermind, invisible buttons don't work, will see if I can set the opacity to 0

Edit2: having a Visible button with the css style set like this:

Image

will make it invisible while functionnal it seems with this condition

Image

all you have to do is to have the button over the actual thing you want the user to click and firefox seems to not mind, only tested in preview though

Edit3: https://1drv.ms/u/s!AjkoCSebIn9Jix06aurQIbxLVv-J just did a capx to show it, it places the button over the sprite and sets its opacity to 0 when created, then it basically uses the >on clicked of the button object and firefox seems to not mind at all, result testable here: http://testing-stuff-out-open-url-firef ... alloon.com
Game design is all about decomposing the core of your game so it becomes simple instructions.
B
52
S
22
G
18
Posts: 2,122
Reputation: 17,093

Post » Fri Oct 28, 2016 6:41 pm

Yes, your trick works, thanks, So to all links to social profiles and other things like upload score i have to add a invisible button? arggg :(

Mmmm so seems depending which object is clicked, construct2 open the new tab in different way? or i'm missing something?

And there is no way to do the same only with click on a object(sprite) ? Why that difference?

At least now i know C2 can do it, i will keep trying to see if i can achieve the same thing without add invisible buttons in all the layouts.

Maybe @ashley can fix that on sprites for next release?
B
23
S
10
G
3
Posts: 542
Reputation: 4,434

Post » Fri Oct 28, 2016 6:49 pm

I think this has to do with the fact form controls are not inside the canvas, but rather part of the actual webpage (which is why they are always on top and lags when moving), so firefox may say "that is ok, that's a guaranted user gesture on the website right there". Could be wrong though, but I sincerely hope there is a better solution for this.

also in the end I did not used the mouse object at all.
Game design is all about decomposing the core of your game so it becomes simple instructions.
B
52
S
22
G
18
Posts: 2,122
Reputation: 17,093

Post » Fri Oct 28, 2016 9:54 pm

matriax wrote:And why from flash and other games in the same site the external links in a new windows are allowed without problems but the same thing from my game are blocked?


Because they use ActionScript, which is inherently insecure and annoying. :-p
https://www.ravenheart.ca/home
Company name changed to avoid Facebook-type shenanigans

"Someone once told me I bite off more than I can chew...

I told them I would rather choke on greatness than nibble on mediocrity."
B
22
S
6
G
1
Posts: 1,414
Reputation: 4,822

Post » Wed Aug 09, 2017 12:14 pm

@Aphrodite you are the best man! Your trick worked perfectly! Thanks, man!
B
3
Posts: 8
Reputation: 202


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 1 guest