После изменения новой вкладки вернитесь и обновите или нажмите кнопку. вниз по окну, и значение возвращается нормально.
Есть ли способ нормально вернуть значение, когда я открываю его в новом окне?
Код: Выделить всё
Document
window.innerWidth + Height before setTimeout()
window.innerWidth + Height after setTimeout()
const $ = document.getElementById.bind(document);
const w1 = $("w1");
const h1 = $("h1");
const w2 = $("w2");
const h2 = $("h2");
const w3 = $("w3");
const h3 = $("h3");
const w4 = $("w4");
const h4 = $("h4");
function onResizeInstant() {
w1.innerText = `w: ${window.innerWidth}`;
h1.innerText = `h: ${window.innerHeight}`;
w3.innerText = `w3: ${document.documentElement.clientWidth}`;
h3.innerText = `h3: ${document.documentElement.clientHeight}`;
window.setTimeout(onResizeTimeout, 5);
}
function onResizeTimeout() {
w2.innerText = `w: ${window.innerWidth}`;
h2.innerText = `h: ${window.innerHeight}`;
w4.innerText = `w4: ${document.documentElement.clientWidth}`;
h4.innerText = `h4: ${document.documentElement.clientHeight}`;
}
window.addEventListener("resize", onResizeInstant);
onResizeInstant();
Я также прилагаю видео этой проблемы.
Видео< /p>
Версия iOS: 17.3.1
Версия Chrome IOS: 122.0.6261.89
Заранее спасибо.
Подробнее здесь: https://stackoverflow.com/questions/781 ... size-wrong
Мобильная версия