HTML5 Is there a function or something I can program in gml to close browser window?

I have an exit button in my game that closes the game. However, in the html5 port, it does nothing. I want to add a simple code in there that closes the browser window. How is this possible? Any help would be greatly appreciated! Thanks! <3
 
I have an exit button in my game that closes the game. However, in the html5 port, it does nothing. I want to add a simple code in there that closes the browser window. How is this possible? Any help would be greatly appreciated! Thanks! <3
Are familiar at all with creating extensions? You may have to create a JS extension and call one of the functions that calls "window.close()". However there are limitations, I believe in certain browsers you can only close a window you opened via JS using "window.open()".
 
Are familiar at all with creating extensions? You may have to create a JS extension and call one of the functions that calls "window.close()". However there are limitations, I believe in certain browsers you can only close a window you opened via JS using "window.open()".
I am still kinda new to exporting in the html5 module. I have figured out how to put it on my own website that I host. I didn't even know you can add extensions to them! it is a shame that I have to resort to javascript. I do have a play button in the game, perhaps I can put a "window.open()" attached to that play button or something? I can also just put another website up that requires the person to click a link before playing that, I can probably add some javascript in there somehow. I am not very familiar with all of this, so i need a mentor lol. Again any help is appreciated, thanks! <3
 
I am still kinda new to exporting in the html5 module. I have figured out how to put it on my own website that I host. I didn't even know you can add extensions to them! it is a shame that I have to resort to javascript. I do have a play button in the game, perhaps I can put a "window.open()" attached to that play button or something? I can also just put another website up that requires the person to click a link before playing that, I can probably add some javascript in there somehow. I am not very familiar with all of this, so i need a mentor lol. Again any help is appreciated, thanks! <3
Well you can add extensions to any project made in GMS, for the windows platform usually extensions use DLLs (Note that the JS extensions will not work in the Windows export). I would suggest having a landing page for your game on your website with a play button, and the play button executes custom JS to open a new tab/window with your game's URL. Then in your extension, have the JS function that will call window.close();

Here's an example of the JS to open the new window (just in case you aren't familiar with JS):
Code:
var gameWindow = window.open(); 
gameWindow.location =  "http://YourURL";
 
Well you can add extensions to any project made in GMS, for the windows platform usually extensions use DLLs (Note that the JS extensions will not work in the Windows export). I would suggest having a landing page for your game on your website with a play button, and the play button executes custom JS to open a new tab/window with your game's URL. Then in your extension, have the JS function that will call window.close();

Here's an example of the JS to open the new window (just in case you aren't familiar with JS):
Code:
var gameWindow = window.open();
gameWindow.location =  "http://YourURL";
I should probably mention that I am not an expert web designer. Could you maybe translate that to "took one html course in high school" language by any chance? Also, where do I put these "extensions" in gamemaker studio 2?
 
I should probably mention that I am not an expert web designer. Could you maybe translate that to "took one html course in high school" language by any chance? Also, where do I put these "extensions" in gamemaker studio 2?
Oh , no problem :p I thought you may have had a little more experience with web development since you're using the HTML5 module :)

First things first though, I would suggest reading up on how to create an extension: GMS 2

Now on your website, do you have a page for the game on your website, not the actual game itself? (a page that may contain information about the game with a "Play" button that will then open the games URL). If you do, then great. If you don't, I suggest familiarizing yourself with web pages again, using HTML and JavaScript.

If you're using a website builder it should be fairly easy, as most website builders that provide a button, also provide a textbox to insert custom JS.
If you have a raw website that you're building on your own, then using this mark up in html will insert a button:
Code:
<button id="btnPlayGame" onclick="OpenGameTab()">Play</button>
And inserting JavaScript into the webpage is as simple as:
Code:
<script type="text/javascript">
        function OpenGameTab() {
                    var gameWindow = window.open();
                    gameWindow.location =  "http://YourURL";
        }
</script>
Then create a custom JS file, simply using any notepad type program will work, this will be the JS file used by the extension.

In your custom file, now insert this JavaScript function:
Code:
function CloseGameTab() {
                    window.close();
        }
If you read the documentation on how to create an extension, it should also help you to link the CloseGameTab function to the game and call it from GML in GMS.

Don't forget, you need to do an explicit check in GML to check that it is the HTML5 module itself, so on your game close do this:
Code:
if (os_browser != browser_not_a_browser) //if the game is being played in a browser
     CloseGameTab(); //Or whatever you name the function in the extension.
Also, some more on checking browsers in the manual here
 
Top