Skip to content

Instantly share code, notes, and snippets.

@flesch
Created October 27, 2009 21:26
Show Gist options
  • Save flesch/219972 to your computer and use it in GitHub Desktop.
Save flesch/219972 to your computer and use it in GitHub Desktop.
Set a window's size
function setSize(w, h) {
if (window.name && w && h) {
var innerWidth, innerHeight, width = Math.floor(w), height = Math.floor(h);
innerWidth = (window.innerWidth || document.documentElement.clientWidth);
innerHeight = (window.innerHeight || document.documentElement.clientHeight);
window.resizeBy(Math.floor(width-innerWidth), Math.floor(height-innerHeight));
window.moveTo(Math.floor((screen.availWidth/2)-(width/2)), Math.floor((screen.availHeight/2)-(height/2)));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment