Take the 2-minute tour ×

I'm developing a web based game using processing.js, my question relates to pure javascript code to manage browser windows.

The game is a maze of small browser windows (200px*200px) each border can be a wall or a passage to another window. My issue is that if I close the window I'm coming from then I try to get back it doesn't re-open, even if I use the same function that was used before.

I've got a git repo running here : GitHub - TheMidst.

If you want to reproduce the "error" :

Pull the code from github:

  1. launch index.html (in your favorite browser, I use chrome).
  2. Don't wait up and click the start button -> level0.html opens.
  3. Go on the right by clicking on the right hand side of the canvas-> level1.html opens.
  4. Go back on your steps -> level0.html still opens.
  5. Go back on the right towards level1.html and it will not be re spawn ... => this is my issue.

/js -> contains a windowScripts.js that handles opening and closing of windows through functions, this is the heart of my window manager and it's buggy.

/levels -> contains each level as a html page.

/pd -> contains the sound of the game as Pure-Data patches (yeah !)

The game is far from finished yet, so everything is far from perfect. Any help would be greatly appreciated.


edited to add some code

to open a popup i use : popUp(1); //1 being the number of the level i want to open.

this relates to this js function

function popUp(winNum) {

var windowFeatures = "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,left="+(winVars[winNum][0])+",top="+(winVars[winNum][1])+",width="+winVars[winNum][2]+",height="+winVars[winNum][3];

windows[winNum] = window.open( "level"+winNum+".html", "myWindow"+winNum, windowFeatures);



all my windows properties are stored in arrays

to close a window I use : closeWindows(0); // 0 being the number of the window I want to close.

function closeWindows(winNum2){

setTimeout (widows[winNum2] = window.close(),50); }

Actually I had a bit of confusion beetween parent windows etc...

using "window.opener.popUp(myPopup)" did fix the issues

some changes have been made on the github repo, if you have the same issue you can still refer to the github repo.


share|improve this question
Maybe you can post some code here where the error occurs? –  David Nov 6 '12 at 15:43
all my code is in the github page. But I actually don't know precisely where the error does occur. I can just guess it might be in the windowScripts.js –  user1803507 Nov 6 '12 at 15:57
add comment

1 Answer

As a general rule, using multiple browser windows is a Bad Idea, because it's exactly the same interface that all sorts of browser malware uses, such as pop-ups and pop-unders. It's entirely possible that's why you're getting the behavior you're seeing, in fact.

Instead, since you want multiple tiles, just use absolutely positioned div elements.

share|improve this answer
yes i know it's a bad idea, but it's actually important conceptually. If I were to use div elements I won't be able to achieve the looks I want : one page per level. –  user1803507 Nov 6 '12 at 15:58
You can get the look you want with one div element per page-level. You don't have to tile them. If you want them to behave like full windows, just use the jQuery UI widget Draggable. –  eh9 Nov 6 '12 at 16:07
I understand that but then all the game will still take place in one window right ? I want to be able to move through several windows, but it's defintely a good workaround if I can't achieve what i want. –  user1803507 Nov 6 '12 at 16:15
It's not a work-around if you consider pop-up blockers something that should work around. Your design is more-or-less indistinguishable from malware. If you want to insist that your users whitelist your application, you might be able to get what you want, but that seems like self-marginalizing behavior. –  eh9 Nov 6 '12 at 16:30
well there will be an explanation on why I did this and the code will be fully visible by the user. Moreover I'm not friendly enough with jquery to be able to set this up in no time and re-write the whole architecture of the game –  user1803507 Nov 6 '12 at 16:41
show 1 more comment

Your Answer


