xgqfrms™, xgqfrms® : xgqfrms's offical website of cnblogs! xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!

how to get window width in javascript All In One

how to get window width in javascript All In One

how to get window width in js

How to Detect Screen Resolution with JavaScript

window

https://developer.mozilla.org/en-US/docs/Web/API/window/innerWidth

https://www.w3schools.com/jsref/prop_win_innerheight.asp

window.innerWidth & window.innerHeight

function innerFunction() {
  var w = window.innerWidth;
  var h = window.innerHeight;
  document.getElementById("demo").innerHTML = "Width: " + w + "<br>Height: " + h;
}

function outerFunction() {
  var w = window.outerWidth;
  var h = window.outerHeight;
  document.getElementById("demo").innerHTML = "Width: " + w + "<br>Height: " + h;
}

screen

https://stackoverflow.com/questions/3437786/get-the-size-of-the-screen-current-web-page-and-browser-window


window.screen.height;
window.screen.width;

viewport size / device size / document size

https://ryanve.com/lab/dimensions/

responsive viewport / viewbox

svg viewbox

small screen

const svgStr = `
<svg data-uuid="live_map_svg" id="live_map_svg" width="100%" height="100%" viewBox="0 0 1000 1000" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"></svg>
`;

body.insertAdjacentHTML(`beforeend`, svgStr.trim());


https://www.tutorialrepublic.com/faq/how-to-detect-screen-resolution-with-javascript.php

https://usefulangle.com/post/190/javascript-window-width-height

refs



©xgqfrms 2012-2020

www.cnblogs.com/xgqfrms 发布文章使用:只允许注册用户才可以访问!

原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究⚠️!


posted @ 2020-03-06 01:27  xgqfrms  阅读(206)  评论(1编辑  收藏  举报