代码示例:(标识:jquery_dim_width_height2)
<!DOCTYPE html>
<html>
<head>
<script src="/jquery/jquery-1.11.1.min.js"></script>
<script>
$(document).ready(function(){
  $("button").click(function(){
    var txt="";
    txt+="Document width/height: " + $(document).width();
    txt+="x" + $(document).height() + "\n";
    txt+="Window width/height: " + $(window).width();
    txt+="x" + $(window).height();
    alert(txt);
  });
});
</script>
</head>
<body>

<button>显示文档和窗口的尺寸</button>

</body>
</html>
运行结果: