1 2 3 4 5 6 7 8 9 10 11 |
$(function() { //ウインドウがリサイズされたら処理 $(window).resize(function() { //ウインドウの高さを変数に格納 var w = $(window).width(); //ウインドウの高さを変数に格納 var h = $(window).height(); //ウインドウの高さをspan要素に出力 $('span').text(h); }); }); |
1 2 3 4 5 6 7 8 9 10 |
<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script> <script> $(function() { var $win = $(window); console.log('コンテンツ本体:' + $win.height() + '×' + $win.width()); console.log('内部余白込み:' + $win.innerHeight() + '×' + $win.innerWidth()); console.log('枠線込み:' + $win.outerHeight() + '×' + $win.outerWidth()); console.log('外部余白込み:' + $win.outerHeight(true) + '×' + $win.outerWidth(true)); }); </script> |