Skip to content

Instantly share code, notes, and snippets.

@vexus2
Created October 24, 2012 03:45
Show Gist options
  • Select an option

  • Save vexus2/3943570 to your computer and use it in GitHub Desktop.

Select an option

Save vexus2/3943570 to your computer and use it in GitHub Desktop.
[Javascript]ブラウザの縦幅、横幅をそれぞれ取得する
function getScreenSize() {
var obj = new Object();
if (!isSafari && !isOpera) {
obj.x = document.documentElement.clientWidth || document.body.clientWidth || document.body.scrollWidth;
obj.y = document.documentElement.clientHeight || document.body.clientHeight || document.body.scrollHeight;
} else {
obj.x = window.innerWidth;
obj.y = window.innerHeight;
}
obj.mx = parseInt((obj.x)/2);
obj.my = parseInt((obj.y)/2);
return obj;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment