Mario: js Probleme mit IE (aktuelle Fensterhoehe)

Beitrag lesen

nun noch die Loesung als funktion

// returns INNER width of window
function getWindowWidth() {
 // if innerWidth is unknown [Internet Explorer] use offsetWidth
  if (window.innerWidth) {
    return window.innerWidth;
  } else if (document.body && document.body.offsetWidth) {
   // important: for IE set body width = 100%
   document.getElementsByTagName("body")[0].style.setAttribute("width", "100%", "false");
    return document.body.offsetWidth;
  } else {
    return 0;
  }
}

// returns INNER height of window
function getWindowHeight() {
 //if innerHeight is unknown [Internet Explorer] use offsetHeight
  if (window.innerHeight) {
    return window.innerHeight;
  } else if (document.body && document.body.offsetHeight) {
 // important: for IE set body height = 100%
 document.getElementsByTagName("body")[0].style.setAttribute("height", "100%", "false");
    return document.body.offsetHeight;
  } else {
    return 0;
  }
}