我在尝试弄清楚为什么这不起作用。 它以前处理高度而不是宽度,但我现在无法让它工作。 也许有人能指点我一下问题的方向吗?
function getWindowWidth() {
var windowWidth = 0;
if (typeof(window.innerWidth) == 'number') {
innerWidth = window.innerWidth;
}
else {
if (document.documentElement && document.documentElement.clientWidth) {
windowWidth = document.documentElement.clientWidth;
}
else {
if (document.body && document.body.clientWidth) {
windowWidth = document.body.clientWidth;
}
}
}
return windowWidth;
}
function Removewhensmall(id) {
if (document.getElementById) {
var windowWidth = getWindowWidth();
if (windowWidth > 0) {
var contentElement = document.getElementById(id);
var contentWidth = contentElement.offsetWidth;
if (windowWidth < 600) {
contentElement.style.display = 'none';
}
}
}
}
window.onload = function() {
Removewhensmall('rightwrap');
Removewhensmall('leftwrap2');
}
window.onresize = function() {
Removewhensmall('rightwrap');
Removewhensmall('leftwrap2');
}