以下代码可以使用纯 JavaScript 或 jQuery 正确找到视口的高度,但如果DOCTYPE未指定,那么报告类似内容的两行410现在都会报告类似3016.
DOCTYPE如果未指定,有没有办法找到视口的高度?
<!DOCTYPE html>
<html>
<head>
<style>
    body { height: 3000px; }
</style>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script>
    onload = function() {
        console.log("jQuery version", $.fn.jquery);
        console.log("document.compatMode is", document.compatMode);
        // using jQuery
        console.log("$(window).height() is", $(window).height());
        // using plain JavaScript
        console.log("document.documentElement.clientHeight is", document.documentElement.clientHeight);
    }
</script>
</head>
<body>
    hi