Forum Moderators: open
The HTML:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head>
<script type="text/javascript">
function height_window(){
if(window.innerHeight)
return window.innerHeight;
if(document.body.clientHeight)
return document.body.clientHeight;
return (null);
}
var isIE=0;
var isOtherBrowser=0;
function pokus() {
if(navigator.appName.indexOf('Microsoft Internet Explorer')!=-1)
{isIE=1;
var height_div=document.getElementById("container_index").scrollHeight;
height=height_window();
document.getElementById('container_index').style.marginTop=(height-height_div)/2+'px';
}
else
{isOtherBrowser =1;
var height_div= document.getElementById("container_index").scrollHeight;
height=height_window();
document.getElementById('container_index').style.marginTop=(height-height_div)/2+'px';
zmena_okna = setTimeout("pokus()", 1);
}
}
</script>
<style>
body {background-color:#666}
#container_index {
margin:0px auto;
text-align:left;
width:700px;
height:300px;
border:1px solid #8faa34;
background: #fff url(../images/theme_1.jpg) right top no-repeat;
}
</style>
</head>
<body onload="pokus();" >
<div id="container_index">
text text text text text text
</div>
</body>
</html>
Second, you should never attempt anything that relies on brower identification, unless you intend on coming back with every new release and fixing it. Test for standard objects you need to perform your task, if the objects are found, execute, if not, do something else. Example,
if (document.getElementById(obj)) { alert('use methods relying on document.getElementById(obj)'); }
Thank you anyway! :)