Я пытаюсь изменить поведение браузера в зависимости от высоты окна. Я хочу, чтобы если пользователь находится в нетбуке, мой script просто активирует css overflow-y до 'auto', поэтому, если контент больше, чем пользователь экрана, он может видеть все. если пользователь находится на большом экране, я хочу, чтобы переполнение было скрытым и у меня был только главный div с overflow = 'auto', поэтому нижний колонтитул может быть внизу экрана, но контент также может быть виден, если он больше экрана.
публикация базового кода для этого, он работает на больших экранах на Mac, но в Internet Explorer он не работает ни на больших, ни на маленьких экранах...
что делать?
Спасибо за помощь заранее
CSS
html, body {
min-width: 600px;
margin: 0;
padding: 0;
overflow: hidden;
}
#header {
position:relative; /* IE7 overflow bug */
clear:both;
float:left;
width:100%;
height: 200px;
overflow: hidden;
}
#main {
position:relative; /* IE7 overflow bug */
clear:both;
float:left;
width:100%;
overflow-x: hidden;
}
#footer {
position:relative; /* IE7 overflow bug */
clear:both;
float:left;
width:100%;
height: 100px;
overflow: hidden;
}
JQuery
if( typeof( window.innerWidth ) == 'number' ) {
// No-IE
var screen_height = window.innerHeight;
} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
//IE 6 +
var screen_height = document.documentElement.clientHeight;
} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
//IE 4
var screen_height = document.body.clientHeight;
}
var header_height = $('#header').height();
var footer_height = $('#footer').height();
var main_height = screen_height - header_height - footer_height;
//
if (navigator.userAgent.toLowerCase().search("iphone") > -1 || navigator.userAgent.toLowerCase().search("ipod") > -1) {
$('body').css('overflow-y', 'auto');
} else {
if(screen_height > 550) {
$('#main').css('height', main_height + 'px');
$('#main').css('overflow-y', 'auto');
} else {
$('html, body').css('overflow-y', 'auto');
}
}