Code: Select all
var sidebar = getObj('sidebar');
function sidebarSize(){
var height = getWinHeight()-12+'px';
sidebar.style.height = height;
sidebar.style.position = 'absolute';
}
function sidebarSticky(){
sidebar.style.top = getScrollY()+6;
}
if(userAgent('IE')){
sidebarSize();
window.onresize = sidebarSize;
window.onscroll = sidebarSticky;
}
Heres the whole thing:
index.html:
Code: Select all
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Insert Title Here</title>
<link rel="stylesheet" href="style.css">
<style type="text/css">
<!--
#sidebar {position:fixed;
background-color:black;
width:175px;
height:auto;
top:6px;bottom:6px;
left:6px;margin:0px 0px;
overflow:auto;}
body {height:60em}
-->
</style>
<script type="text/javascript" src="./scripts/lib.js"></script>
</head>
<body>
<div id="sidebar">
</div>
<script type="text/javascript">
<!--
//use stylesheet if Moz and NS6+ and Opera are not as shitty as
//M$'s IE. Box model in IE not implemented correctly
//Jerky scroll, but oh well. You should be using Mozilla anyways.
var sidebar = getObj('sidebar');
function sidebarSize(){
var height = getWinHeight()-12+'px';
sidebar.style.height = height;
sidebar.style.position = 'absolute';
}
function sidebarSticky(){
sidebar.style.top = getScrollY()+6;
}
if(userAgent('IE')){
sidebarSize();
window.onresize = sidebarSize;
window.onscroll = sidebarSticky;
}
//-->
</script>
</body>
</html>
Code: Select all
function userAgent(UA){
reUA = new RegExp(UA);
return reUA.test(navigator.userAgent);
}
function getObj(objID){
if(document.getElementById){
return document.getElementById(objID);
}else{
return document.all[objID];
}
}
function getWinHeight(){
if((document.all && (document.compatMode == 'BackCompat'))||(!document.all)){//M$ Sucks!!!!!!
return document.body.clientHeight;
}else{
if(document.all){
return document.documentElement.clientHeight;
}
}
}
function getScrollY(){
if((document.all && (document.compatMode == 'BackCompat'))||(!document.all)){ //M$ Sucks!!!!!!
return document.body.scrollTop;
}else{
if(document.all){
return document.documentElement.scrollTop;
}
}
}