问题:
I am trying to write a JavaScript function to get the current browser width.我正在尝试编写一个 JavaScript 函数来获取当前浏览器的宽度。
I found this one:我找到了这个:
javascript:alert(document.body.offsetWidth);
But its problem that it fail if the body has width 100%.但它的问题是,如果主体的宽度为 100%,它就会失败。
Is there any other better function or a workaround?还有其他更好的功能或解决方法吗?
解决方案:
参考一: https://en.stackoom.com/question/4MDf参考二: https://stackoom.com/question/4MDf