iPad Chrome 在新选项卡中打开页面时高度错误

问题描述 投票:0回答:1

iPad 信息 型号名称:Ipad(第9代) 软件版本:15.4.1

Chrome 信息 版本:121.0.6167.138

我看到一个问题$(window).height();当我在新选项卡中打开页面时(target =“_blank”)。 我有两个这样的 html 页面:

Page01.html

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <meta name="viewport" content="width=Device-Width, initial-scale=1">
    <!-- <script type="text/javascript" src="JS_CSS/JS/jquery.js"></script> -->
    <script src="https://code.jquery.com/jquery-2.2.4.js" integrity="sha256-iT6Q9iMJYuQiMWNd9lDyBUStIq/8PuOW33aOqmvFpqI=" crossorigin="anonymous"></script>
    <script >
        $(document).ready(function () {
            var heightWin =  $(window).height()
            alert('Win height: ' + heightWin);
        });
    </script>
    <style>
    </style>
</head>
<body>
    <form id="form1" runat="server">

        <div style="width: 100%; border: solid 2px red;  box-sizing:border-box" class="my-element">
            <a href="https://nghiashare.w3spaces.com/Page02.html" target="_self"> WebForm2.aspx _self</a>
            <br />
            <br />
            <a href="https://nghiashare.w3spaces.com/Page02.html" target="_blank">WebForm2.aspx _blank</a>
        </div>
    </form>
</body>
</html>

当我点击Page01.html中的“WebForm2.aspx _self”链接时,Chrome警报heightWin为965

当我点击 Page01.html 中的“WebForm2.aspx _blank”链接时,Chrome 警报 heightWin 为 1060

该问题仅发生在 Chrome 上。如果我用safari就没有问题

您可以尝试在链接中在线访问我的示例 https://nghiashare.w3spaces.com/page01.html

非常感谢您向我建议此问题的原因和解决方案。 你的。 义

javascript jquery css google-chrome ipad
1个回答
0
投票

根据您要阅读的大小,浏览器提供两个值:

第一个返回带有框架的窗口的大小, 第二个返回带有内容的窗口的内部大小(视口)

window.outerHeight
window.innerHeight

© www.soinside.com 2019 - 2024. All rights reserved.