tags:

views:

77

answers:

3

A friend had phoned me the other day asking for the best way to manage a list of windows (keeping them in order) so he can promote the next window to the top-level when the current top-level window is closed. This is for a web application, so we're using jQuery Javascript.

We'd talked through a few simplistic solutions, such as using an array and just treating [0] index as the top-most window.

I'm wondering if there's any potentially more efficient or useful alternative to what we had brainstormed.

A: 

I don't really know javascript, but couldn't you create a stack of windows?

niklasfi
A: 

A stack if you want to just close the window on top. A queue if you also need to open windows at the end.

kokos
A: 

Stack/queue in JS is a simple array, which can be manipulated with .push(val), .pop(), .shift(val) and .unshift().

Nickolay