mercredi 22 avril 2015

Make child windows appear at random locations

http://ift.tt/1HiYYql

^^ I just received some help in putting a small website together, and now I have a different idea for it.

http://ift.tt/1cYSzE8

Whenever I click on one of the buttons, up to 5 child windows appear, and they all appear centered on the screen, because of the script below that tells them to do so. This was fine when only one window was opening, but now they all appear on top of each other. Is there any way I can change this to make the windows appear at random locations?

function wopen(url, name, w, h)
{

  w += 32;
  h += 96;
  wleft = (screen.width - w) / 2;
  wtop = (screen.height - h) / 2;

  if (wleft < 0) {
    w = screen.width;
    wleft = 0;
  }
  if (wtop < 0) {
    h = screen.height;
    wtop = 0;
  }
  var win = window.open(url, name,
    'width=' + w + ', height=' + h + ', ' +
    'left=' + wleft + ', top=' + wtop + ', ' +
    'location=no, menubar=no, ' +
    'status=no, toolbar=no, scrollbars=no, resizable=no');

  win.resizeTo(w, h);

  win.moveTo(wleft, wtop);
  win.focus();
}




Aucun commentaire:

Enregistrer un commentaire