How to Resize Current Window?

Dcoder
13 Dec 2017, 13:43This question is for any JS masters out there (i.e., KV)...
I'm doing a desktop TA. I'm trying to resize the current Quest window using javascript. I looked at these two links:
https://www.w3schools.com/jsref/met_win_resizeto.asp
https://www.w3schools.com/jsref/met_win_focus.asp
Still couldn't get it to work. You might have to walk me through it from step one. Thanks.

K.V.
13 Dec 2017, 17:35Hello.
Are you trying to resize the actual Quest window? Or create a new window and resize that?
If you can open popup windows inside of the desktop version Quest, I haven't figured out how. (I think that's why Alex set up the dialog
element.)
Those codes you linked to will open a new window when playing in a browser, but not in the desktop player.
When playing online this will open a new window, write the text to it, then shrink its size after 5 seconds:
JS.eval ("myWindow = window.open('', '', 'width=600, height=800');myWindow.document.write('<h1>Welcome to the new window!</h1>');setTimeout(function(){myWindow.resizeTo(400,400);}, 5000);")
It messes up the desktop player, though. window.open
breaks my game every time in the desktop player. I just get a blank screen. (I don't think the built-in Chromium browser can have more than one window running.)
So, in the desktop player, try this on for size:
JS.eval ("var myWindow = $('#gameBorder');$('#status, #gamePanes').css('position','absolute');myWindow.dialog({height: 600, width: 1000});")
Back to online play:
When I play online, I click 'Play' (either from the editor or from a game's main page), and the game opens in a new tab.
Now, if the game is in a window of its own, you can do JS.eval ("window.resizeTo(400,400);")
, and your actual game's window will resize.
Confused?
Because I'm not sure if I am or not...

K.V.
13 Dec 2017, 19:34For the web player, you can use this line to pop the game out into a window of its own:
JS.eval ("if(sessionStorage.sawThis != 'once'){sessionStorage.sawThis = 'justnow';};if(sessionStorage.sawThis != 'once'){sessionStorage.sawThis = 'once'; myWindow = window.open('', '', 'width=600, height=800');var myHtml = $('html').html();myWindow.document.write(myHtml);setTimeout(function(){sessionStorage.sawThis = '';window.close();},500);};resizeWindow = function(x,y){window.resizeTo(parseInt(x),parseInt(y));};resizeWindow(300,300);")
Then, you can use the resizeWindow() function forever after.
NOTE: This disables the links and messes up the panes when I play the game, but entering commands still works. (I'm testing from the online editor, so it may be different when playing a real game.
ALSO: You have to have popups enabled for this to work in the web player, and remember: it doesn't do anything but mess the game up in the desktop player.

K.V.
13 Dec 2017, 20:04http://textadventures.co.uk/games/view/sb7nspqkf0ijoko8z5ixzg/popping-the-window-out-then-resizing-it
Only play online.
Popups must be allowed.
After the window shrinks down, without resizing it yourself, enter the command OPEN DOOR. (The links will not work, but the window should resize.)

Dcoder
14 Dec 2017, 07:06Thanks for the responses, KV.
I'm trying to resize the actual Quest window in desktop play only. I tried one of your suggestions:
JS.eval ("var myWindow = $('#gameBorder');$('#status, #gamePanes').css('position','absolute');myWindow.dialog({height: 600, width: 1000});")
It was on the right track of what I wanted, but I wasn't looking for a second window. It sounds like it's probably not possible to resize the original window in desktop play.
The Pixie
14 Dec 2017, 08:18I do not think you can change the window with JavaScript. Quest has a web page embedded in the software, and JavaScript can do stuff within that web page, but I would be very surprised if it can do anything outside of that, such as changing the window size. KV got around that by spawning a new window, which is in effect inside the web page, so JavaScript can do stuff to it.