I'm trying to figure out with this isn't working. It used to take care of height instead of width, but i simply can't get it it work. Anyone could point me in the right direction of the problem perhaps?
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');
}
if (typeof(window.innerWidth) == 'number') {
innerWidth = window.innerWidth;
}
shouldn't that be
if (typeof(window.innerWidth) == 'number') {
windowWidth = window.innerWidth;
}
?
And further in the code
var contentWidth = contentElement.offsetWidth;
is defined, but contentWidth is never used again...
Also, you should make use of elseif() to prevent many nested if-clausules.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With