Developer

Move windows dynamically

Dynamically moving windows let Web builders arrange and rearrange windows to optimize information display. Learn how to dynamically move windows.

By Brent Lee Metcalfe

When all is said and done, windows that move are more practical than cool (but perhaps that's what makes them cool). But, if used with restraint, dynamically moving windows let Web builders arrange and rearrange windows to optimize information display.

The code for moving a window looks a lot like the code for resizing a window:

var x = 0;

function moveMe() {
  if (x == 0) {
    self.moveBy(200,200);
    x = 1;
  }
    else {
      if (x == 1) {
        self.moveBy(-200,-200);
        x = 0;
      }
    }
}

In this case, function moveMe() lets users toggle between moving the window from one location then back using the moveBy() method. moveBy() is distinguished from the moveTo() in that the former is relative and the latter absolute.

Brent Lee Metcalfe is a Web architecture consultant.

Editor's Picks

Free Newsletters, In your Inbox