
Originally Posted by
Zaph - from a private message
Hi there,
Thanks for the help with this one.
I'm having a problem incorporating the script for a different use though. I have a very large table, and wanted to use the script to make the column headers float in a sort of excel/freeze panes style.
The problem I have though is it is too high, centred and when I scroll horizontally it moves with the scroll.
Is it going to be easy to fix these issues?
Thanks again.
Well, fix is not exactly the word I would use. The code to float content was taken pretty much from the tutorial I mentioned above. I 'enhanced' it for my demo to center and to include the drop down menus. Here it is unaltered but commented to show where positioning can be done:
HTML Code:
<div id="staticbanner" style="position:absolute;">
Advertisement<br>
<a href="http://test.htm"><img
src="test.gif" width="120" height="90" alt="Click here!"
border="0"></a>
</div>
Code:
<script>
//define universal reference to "staticbanner"
var crossobj=document.all? document.all.staticbanner : document.getElementById? document.getElementById("staticbanner") : document.staticbanner
function positionit(){
//define universal dsoc left point
var dsocleft=document.all? document.body.scrollLeft : pageXOffset
//define universal dsoc top point
var dsoctop=document.all? document.body.scrollTop : pageYOffset
//define universal browser window width
var window_width=document.all? document.body.clientWidth : window.innerWidth
//if the user is using IE 4+ or NS6+
if (document.all||document.getElementById){
crossobj.style.left=parseInt(dsocleft)+
parseInt(window_width)-135 //position left coord for IE4+ & NS6+
crossobj.style.top=dsoctop+5 //position top coord for IE4+ & NS6+
}
//else if the user is using NS 4
else if (document.layers){
crossobj.left=
dsocleft+window_width-140 //position left coord
crossobj.top=dsoctop+15 //position top coord
}
}
setInterval("positionit()",200)
</script>
To get it to not follow the scroll left to right change this:
Code:
crossobj.style.left=parseInt(dsocleft)+
parseInt(window_width)-135 //position left coord
to:
Code:
crossobj.style.left=135+'px' //position left coord
and this:
Code:
crossobj.left=
dsocleft+window_width-140 //position left coord
to:
Code:
crossobj.left=135+'px' //position left coord
For a different top coord just change the number added.
Bookmarks