« java、jQueryでクロスブラウザ対応。 | ホーム | jQueryを使って、クリックすると伸びるように出現するパーツをつくる。 »
2011年3月22日
javaでブラウザサイズを取得する。
閲覧者のブラウザのサイズを取得するjavaを調べたのでメモします。
http://osima.jp/blog/js-getBrowserWidth/より引用
http://osima.jp/blog/js-getBrowserWidth/より引用
//▼ブラウザの横幅を取得 function getBrowserWidth() { if ( window.innerWidth ) { return window.innerWidth; } else if ( document.documentElement && document.documentElement.clientWidth != 0 ) { return document.documentElement.clientWidth; } else if ( document.body ) { return document.body.clientWidth; } return 0; } //▼ブラウザの縦幅を取得 function getBrowserHeight() { if ( window.innerHeight ) { return window.innerHeight; } else if ( document.documentElement && document.documentElement.clientHeight != 0 ) { return document.documentElement.clientHeight; } else if ( document.body ) { return document.body.clientHeight; } return 0; }