サンプル
サンプル1
ボタンをクリックすると、高さを表示します。
サンプルプログラムはiframe内で動いているので、windowの高さは黄色い部分の値になります。予期したよりも小さい値が表示されているかもしれません。その場合は、単独で開いて確認してみて下さい。
<button id="getp">Get Paragraph Height</button>
<button id="getd">Get Document Height</button>
<button id="getw">Get Window Height</button>
<div> </div>
<p>
Sample paragraph to test height
</p>
function showHeight(ele, h) {
$("div").text("The height for the " + ele +
" is " + h + "px.");
}
$("#getp").click(function () {
showHeight("paragraph", $("p").height());
});
$("#getd").click(function () {
showHeight("document", $(document).height());
});
$("#getw").click(function () {
showHeight("window", $(window).height());
});
[
フレーム]