{"id":1442,"date":"2020-12-01T21:30:29","date_gmt":"2020-12-01T12:30:29","guid":{"rendered":"https:\/\/www.wetch.co.jp\/?p=1442"},"modified":"2022-01-14T23:20:23","modified_gmt":"2022-01-14T14:20:23","slug":"%e3%80%90javascript%e3%80%91window-innerheight%e3%81%a3%e3%81%a6%e3%81%a9%e3%81%93%e3%81%ae%e9%ab%98%e3%81%95%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/www.wetch.co.jp\/note\/%e3%80%90javascript%e3%80%91window-innerheight%e3%81%a3%e3%81%a6%e3%81%a9%e3%81%93%e3%81%ae%e9%ab%98%e3%81%95%ef%bc%9f\/","title":{"rendered":"\u3010javascript\u3011window.innerHeight\u3063\u3066\u3069\u3053\u306e\u9ad8\u3055\uff1f"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">\u30b3\u30fc\u30c7\u30a3\u30f3\u30b0\u3059\u308b\u6642\u3001\u7279\u306b\u30ec\u30b9\u30dd\u30f3\u30b7\u30d6\u30b5\u30a4\u30c8\u306a\u3069\u3067\u306f\u3001<br>\u4f55\u304b\u3068\u52d5\u7684\u306b\u9ad8\u3055\u3092\u8abf\u6574\u3057\u305f\u304f\u306a\u308b\u6642\u304c\u3042\u308b\u304b\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6bce\u56de\u300c\u3069\u306e\u30d7\u30ed\u30d1\u30c6\u30a3\u4f7f\u3048\u3070\u3001\u3069\u3053\u306e\u9ad8\u3055\u304c\u53d6\u5f97\u3067\u304d\u308b\u3093\u3060\u3063\u3051\uff1f\u300d\u3068<br>\u6df7\u4e71\u3057\u3066\u3044\u305f\u306e\u3067\u307e\u3068\u3081\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>screen.height = \u30b9\u30af\u30ea\u30fc\u30f3\u306e\u9ad8\u3055\uff08\u30c7\u30a3\u30b9\u30d7\u30ec\u30a4\u5168\u4f53\uff09<\/li><li>screen.availHeight = \u30b9\u30af\u30ea\u30fc\u30f3\u306e\u6709\u52b9\u9818\u57df\u306e\u9ad8\u3055<\/li><li>window.outerHeight = \u30d6\u30e9\u30a6\u30b6\u5168\u4f53\u306e\u9ad8\u3055<\/li><li>window.innerHeight = \u30d6\u30e9\u30a6\u30b6\u306e\u5185\u5074\u306e\u9ad8\u3055\uff08\u30da\u30fc\u30b8\u304c\u8868\u793a\u3055\u308c\u308b\u9ad8\u3055\uff09<\/li><li>document.documentElement.clientHeight = \u30da\u30fc\u30b8\u304c\u8868\u793a\u3055\u308c\u308b\u9ad8\u3055<\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e0b\u306e\u30ea\u30f3\u30af\u30dc\u30bf\u30f3\u3092\u30af\u30ea\u30c3\u30af\u3067<br>\u5b9f\u969b\u306b\u53d6\u5f97\u3057\u305f\u5024\u3092\u8868\u793a\u3057\u307e\u3059\u3002<br><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u7279\u306b\u30b9\u30de\u30db\u3067\u306f\u3001\u30a2\u30c9\u30ec\u30b9\u30d0\u30fc\u306e\u8868\u793a\/\u975e\u8868\u793a\u3067<br>\u5024\u304c\u5909\u308f\u3063\u3066\u304f\u308b\u306e\u3067\u8272\u3005\u8a66\u3057\u3066\u307f\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n\n\n\n<div class=\"demo\">\n\t<p><strong>DEMO<\/strong><\/p>\n\t<a id=\"getHeight\" class=\"btn\">\u9ad8\u3055<\/a>\n\t<p>screen.height = <span id=\"01\">0<\/span><\/p>\n\t<p>screen.availHeight = <span id=\"02\">0<\/span><\/p>\n\t<p>window.outerHeight = <span id=\"03\">0<\/span><\/p>\n\t<p>window.innerHeight = <span id=\"04\">0<\/span><\/p>\n\t<p>document.documentElement.clientHeight = <span id=\"05\">0<\/span><\/p>\n<\/div>\n\n<style>\n\t.demo{\n\t\tborder: 1px solid #E8E8E7;\n\t\tpadding: 30px;\n\t}\n\t.btn{\n\t\tdisplay: inline-block;\n\t\tbackground-color:#57B196;\n\t\tcolor: #fff;\n\t\tpadding:20px 50px;\n\t\tborder-radius: 10px;\n\t\tmargin-bottom: 30px;\n\t\ttransition-duration: .7s;\n\t}\n\t.btn:hover{\n\t\topacity: 0.7;\n\t}\n<\/style>\n\n<script>\n\tconst height = document.getElementById('getHeight');\n\theight.addEventListener('click', function(){\n\t\tconst screenHeight = screen.height;\n\t\tconst screenAvailHeight = screen.availHeight;\n\t\tconst windowOuterHeight = window.outerHeight;\n\t\tconst windowInnerHeight = window.innerHeight;\n\t\tconst docClientHeight = document.documentElement.clientHeight;\n\t\tdocument.getElementById('01').innerHTML = screenHeight;\n\t\tdocument.getElementById('02').innerHTML = screenAvailHeight;\n\t\tdocument.getElementById('03').innerHTML = windowOuterHeight;\n\t\tdocument.getElementById('04').innerHTML = windowInnerHeight;\n\t\tdocument.getElementById('05').innerHTML = docClientHeight;\n\t});\n<\/script>\n\n\n\n<p class=\"wp-block-paragraph\" style=\"margin-top:30px\">\u7c21\u5358\u3067\u3059\u304cscript\u306f\u3053\u3061\u3089<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;script>\n\tconst height = document.getElementById('getHeight');\n\theight.addEventListener('click', function(){\n\t\tconst screenHeight = screen.height;\n\t\tconst screenAvailHeight = screen.availHeight;\n\t\tconst windowOuterHeight = window.outerHeight;\n\t\tconst windowInnerHeight = window.innerHeight;\n\t\tconst docClientHeight = document.documentElement.clientHeight;\n\t\tdocument.getElementById('01').innerHTML = screenHeight;\n\t\tdocument.getElementById('02').innerHTML = screenAvailHeight;\n\t\tdocument.getElementById('03').innerHTML = windowOuterHeight;\n\t\tdocument.getElementById('04').innerHTML = windowInnerHeight;\n\t\tdocument.getElementById('05').innerHTML = docClientHeight;\n\t});\n&lt;\/script><\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\" style=\"margin-top:30px\">\u4ed6\u306b\u3082\u8272\u3005\u53d6\u5f97\u65b9\u6cd5\u3042\u308a\u305d\u3046\u306a\u306e\u3067\u3001\u8a66\u3057\u3066\u307f\u305f\u3044\u3067\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u30b3\u30fc\u30c7\u30a3\u30f3\u30b0\u3059\u308b\u6642\u3001\u7279\u306b\u30ec\u30b9\u30dd\u30f3\u30b7\u30d6\u30b5\u30a4\u30c8\u306a\u3069\u3067\u306f\u3001\u4f55\u304b\u3068\u52d5\u7684\u306b\u9ad8\u3055\u3092\u8abf\u6574\u3057\u305f\u304f\u306a\u308b\u6642\u304c\u3042\u308b\u304b\u3068\u601d\u3044\u307e\u3059\u3002 \u6bce\u56de\u300c\u3069\u306e\u30d7\u30ed\u30d1\u30c6\u30a3\u4f7f\u3048\u3070\u3001\u3069\u3053\u306e\u9ad8\u3055\u304c\u53d6\u5f97\u3067\u304d\u308b\u3093\u3060\u3063\u3051\uff1f\u300d\u3068\u6df7\u4e71\u3057\u3066\u3044\u305f\u306e\u3067\u307e\u3068\u3081\u3066\u307f\u307e\u3057\u305f\u3002 screen [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1469,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":"","_wp_rev_ctl_limit":""},"categories":[214],"tags":[24,37],"class_list":["post-1442","post","type-post","status-publish","format-standard","has-post-thumbnail","category-214","tag-web","tag-javascript"],"_links":{"self":[{"href":"https:\/\/www.wetch.co.jp\/note\/wp-json\/wp\/v2\/posts\/1442","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wetch.co.jp\/note\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wetch.co.jp\/note\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wetch.co.jp\/note\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wetch.co.jp\/note\/wp-json\/wp\/v2\/comments?post=1442"}],"version-history":[{"count":0,"href":"https:\/\/www.wetch.co.jp\/note\/wp-json\/wp\/v2\/posts\/1442\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wetch.co.jp\/note\/wp-json\/wp\/v2\/media\/1469"}],"wp:attachment":[{"href":"https:\/\/www.wetch.co.jp\/note\/wp-json\/wp\/v2\/media?parent=1442"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wetch.co.jp\/note\/wp-json\/wp\/v2\/categories?post=1442"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wetch.co.jp\/note\/wp-json\/wp\/v2\/tags?post=1442"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}