Created
October 27, 2009 21:26
-
-
Save flesch/219972 to your computer and use it in GitHub Desktop.
Set a window's size
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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