同一个页面, chrome 通过 http://localhost/和 http://127.0.0.1/访问, viewpoint 居然不一样

2019-01-30 09:18:23 +08:00
 fangdingjun

测试代码如下

<!DOCTYPE html>
<html>
<head>
    <script>
        window.onload = function () {
            document.write("body width " + document.body.clientWidth + " px");
        };
    </script>
</head>
<body>
</body>
</html>

以上代码保存为 index.html

启动一个 http server

python2 -m SimpleHTTPServer 8001

python3 -m http.server 8001

chrome 通过 http://127.0.0.1:8001/ 访问, body width 是 1904 px

通过 http://localhost:8001/访问, body width 是 3824 px

firefox 访问两个地址, body width 都是 1904 px,

chrome 好神奇,通过 http://localhost/ 访问,页面的的字体,按钮都会变小,

环境 win7 64 位, chrome 71.0.3578.98.

3134 次点击
所在节点    浏览器
3 条回复
kenorizon
2019-01-30 09:30:58 +08:00
看下 Chrome 在 localhost 下是不是什么时候进行了缩放,被 Chrome 记忆了。
fangdingjun
2019-01-30 09:38:32 +08:00
还真是缩放的问题,重置一下就好了,非常感谢!
oszlso
2019-01-30 11:05:56 +08:00

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/531773

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX