Javascript clientWidth、screen.width、android Chrome和viewport
我有三个子问题。我用android Chrome在我的android手机(720*1280)上运行了以下Java脚本。当页面开始加载时,我在windown.onload中运行了它。但是我得到了如下奇怪的结果Javascript clientWidth、screen.width、android Chrome和viewport,javascript,Javascript,我有三个子问题。我用android Chrome在我的android手机(720*1280)上运行了以下Java脚本。当页面开始加载时,我在windown.onload中运行了它。但是我得到了如下奇怪的结果 为什么body.clientwidth比screen.width大(无论是否添加viewport meta,我都得到了相同的结果) 为什么它在android Chrome上返回360*640,而在其他浏览器(如UC)上返回正确的分辨率?如何使用android chrome获得正确的分辨率 我
//当页面开始加载时,使用Android UC浏览器执行
文件写入(窗口、屏幕、宽度);
书面文件(“
”);
文件写入(窗口、屏幕、高度);
书面文件(“
”);
document.writeln(document.body.clientWidth);
书面文件(“
”);
document.writeln(document.body.clientHeight);
720
1280
964
114
//在window.onload中使用Android UC浏览器执行
文件写入(窗口、屏幕、宽度);
书面文件(“
”);
文件写入(窗口、屏幕、高度);
书面文件(“
”);
document.writeln(document.body.clientWidth);
书面文件(“
”);
document.writeln(document.body.clientHeight);
720
1280
964
266
//当页面开始加载时,在Android Chrome中执行
文件写入(窗口、屏幕、宽度);
书面文件(“
”);
文件写入(窗口、屏幕、高度);
书面文件(“
”);
document.writeln(document.body.clientWidth);
书面文件(“
”);
document.writeln(document.body.clientHeight);
360
640
360
640
32
964
132
//在Android Chrome window.onload中执行
文件写入(窗口、屏幕、宽度);
书面文件(“
”);
文件写入(窗口、屏幕、高度);
书面文件(“
”);
document.writeln(document.body.clientWidth);
书面文件(“
”);
document.writeln(document.body.clientHeight);
360
640
360
640
32
964
308
我认为这个问题(这些问题?)太宽泛了。可能的解决方案的一部分可能会在一个快速的步骤中找到:考虑使用<代码>控制台。()(代码)>代码>和浏览器的开发工具,而不是<代码>文档>()
//execute with Android UC browser when page starts to load
document.writeln(window.screen.width);
document.writeln("<br />");
document.writeln(window.screen.height);
document.writeln("<br />");
document.writeln(document.body.clientWidth);
document.writeln("<br />");
document.writeln(document.body.clientHeight);
720
1280
964
114
//execute with Android UC browser in window.onload
document.writeln(window.screen.width);
document.writeln("<br />");
document.writeln(window.screen.height);
document.writeln("<br />");
document.writeln(document.body.clientWidth);
document.writeln("<br />");
document.writeln(document.body.clientHeight);
720
1280
964
266
//execute in Android Chrome when page starts to load
document.writeln(window.screen.width);
document.writeln("<br />");
document.writeln(window.screen.height);
document.writeln("<br />");
document.writeln(document.body.clientWidth);
document.writeln("<br />");
document.writeln(document.body.clientHeight);
360
640
360
640
32
964
132
//execute in Android Chrome window.onload
document.writeln(window.screen.width);
document.writeln("<br />");
document.writeln(window.screen.height);
document.writeln("<br />");
document.writeln(document.body.clientWidth);
document.writeln("<br />");
document.writeln(document.body.clientHeight);
360
640
360
640
32
964
308