Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / "OpenBrowser()" + HTML5 - Open In Same Browser Tab Where Game Is Running?

Author
Message
JeZxLee
7
Years of Service
User Offline
Joined: 15th Mar 2017
Location: Long Island, New York, United States, Earth
Posted: 6th Dec 2017 22:18 Edited at: 6th Dec 2017 22:57
Hi,

I love AppGameKit.
I use it to make 2D games for both Android and HTML5.

On HTML5 version I would like to use "OpenBrowser()" on game exit
to open my studio's website in the same browser tab that the game was running in.

Is the above possible?
Thanks!
JeZxLee
16BitSoft
Video Game Design Studio
http://www.16BitSoft.com
Open-Source AppGameKit Project!
JeZxLee
7
Years of Service
User Offline
Joined: 15th Mar 2017
Location: Long Island, New York, United States, Earth
Posted: 7th Dec 2017 11:14
Hi Again!

Would it be possible to build HTML5 with obfuscation off?
Then I can modify the JS to open the website in same browser tab.
Thanks!
JeZxLee
16BitSoft
Video Game Design Studio
http://www.16BitSoft.com
Open-Source AppGameKit Project!
xCept
21
Years of Service
User Offline
Joined: 15th Dec 2002
Location:
Posted: 7th Dec 2017 22:09 Edited at: 7th Dec 2017 22:10
I admit I haven't done much with HTML5 export yet, but along those lines it would be extremely beneficial for AppGameKit to support calling JavaScript functions from the same HTML5 page. You could then have a standard JS function programmed on the page and could pass values to it from an AppGameKit command, and vice versa. If this were possible then you could simply define a JS function redirectUser(url) and pass the URL from AppGameKit to it, then do a simple window.target update via JavaScript. JavaScript communication for HTML5 exported apps would be valuable for infinite reasons, without having to deal with server-side HTTP queries and such.
JeZxLee
7
Years of Service
User Offline
Joined: 15th Mar 2017
Location: Long Island, New York, United States, Earth
Posted: 7th Dec 2017 22:42
Ugggg...

Got the very 1st pre-alpha test live on below website URL address:

http://16bitsoft.com/files/DigitalCrack/DC-HTML5/DigitalCrack.html

Problem is all Internet browsers block the new URL link as a "PopUp"
Can someone suggest a fix with some code?
I looked at the generated JS and yup it's completely obfuscated...

Thanks!
JeZxLee
16BitSoft
Video Game Design Studio
http://www.16BitSoft.com
Open-Source AppGameKit Project!
xCept
21
Years of Service
User Offline
Joined: 15th Dec 2002
Location:
Posted: 8th Dec 2017 07:58 Edited at: 8th Dec 2017 08:05
I just took a look at the generated code and here is the solution. This simple modification in AGKPlayer.js will open the requested URL in the same window so it will not trigger the pop-up blocker and is exactly what you were trying to achieve.

1.) Open AGKPlayer.js

2.) Do a search for: _blank

3.) Replace _blank with _self

4.) Save the file, reupload it to your server replacing the existing one, and then press CTRL+F5 on the page to clear the cache to ensure the latest JavaScript version is loaded.

That is it. Now when OpenBrowser() is called the page will replace the existing one. TGC should consider making this modification themselves as otherwise in every modern browser the requested page will likely be blocked due to how the function is called via the HTML5 AppGameKit context (which browsers see as non-user triggered).

EDIT: I've also confirmed a similar approach can be taken to easily communicate with externally defined JavaScript functions as well, which can be used to open a URL in a new window/tab without triggering the pop-up block alert. This makes it easy to pass data to standard JavaScript and then perform any common functions there (alerts etc.) I may make a thread describing this in more detail at some point.
JeZxLee
7
Years of Service
User Offline
Joined: 15th Mar 2017
Location: Long Island, New York, United States, Earth
Posted: 8th Dec 2017 10:34
Hi!

THAT WORKS!!!!
Mega thank you to you, you saved me!

Below is the URL to the HTML5 version
http://16bitsoft.com/files/DigitalCrack/DC-HTML5/DigitalCrack.html

Thanks again, continuing with develpment!
JeZxLee
16BitSoft
Video Game Design Studio
http://www.16BitSoft.com
Open-Source AppGameKit Project!

Login to post a reply

Server time is: 2024-04-19 18:35:49
Your offset time is: 2024-04-19 18:35:49