ブラウザで開いているスペースの現在の高さと幅を取得する方法を教えてください。HTML DOMの幅+可視ウィンドウの高さ
私はドキュメント全体の高さを望んでいません。画面上に表示されているものだけです。
ブラウザで開いているスペースの現在の高さと幅を取得する方法を教えてください。HTML DOMの幅+可視ウィンドウの高さ
私はドキュメント全体の高さを望んでいません。画面上に表示されているものだけです。
この方法を見るにはblog postをご覧ください。
と短い中でもJSフレームワーク(jqueryの、内線、試作品)のほとんどは(私見)ことを行うための機能を提供することに注意する必要がそのコードに
function alertSize() {
var myWidth = 0, myHeight = 0;
if(typeof(window.innerWidth) == 'number') {
// Non-IE
myWidth = window.innerWidth;
myHeight = window.innerHeight;
}
else if(document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
// IE 6+ in 'standards compliant mode'
myWidth = document.documentElement.clientWidth;
myHeight = document.documentElement.clientHeight;
}
else if(document.body && (document.body.clientWidth || document.body.clientHeight)) {
// IE 4 compatible
myWidth = document.body.clientWidth;
myHeight = document.body.clientHeight;
}
window.alert('Width = ' + myWidth);
window.alert('Height = ' + myHeight);
}
を与えます。 jQueryので
:その後、
$(window).width();
$(window).height();
<html id="THE_HTML">
<!-- all your stuff... -->
</html>
:
document.getElementById('THE_HTML').clientHeight;
検査済みとIE8とFF3.6の下で働いて...ウィンドウは、プロパティ、内側の高さをオブジェクト
使用/ widthを使用して、Webページ上のコンテンツのサイズを検索します。これにはスクロールバーが含まれます。ここに視覚的な説明 - >http://goo.gl/L0cBLAがあります。
身長:
window.innerHeight
幅:
window.innerWidth
私はjQueryのを使用するが、これはこの枠組みの中で可能ですか? –
@ BahaiResearch.com:私は編集しました。 – RageZ
-1 jQueryは可視領域の高さと幅を返しません。ユーザーがスクロールできる高さと幅を返します。 – schlingel