PDA

View Full Version : almost static layer


andre73
01-23-2003, 01:21 PM
Hi there!
I am wondering if anyone is able to help me with a script.
I need to have a layer that is visible at the screen at all
times even if the user scrolls. I am aware that you can
find plenty of scripts which will solve this problem. However,
I need the layer to be at position left 25 and top 200
when the page loads, then as the user scrolls I want
the layer to scroll along up to the top of the browser
window and then not scroll any longer, I want it to remain
in the top of the browser even if you continue to scroll.
And when you scroll back down to the initial position the
layer should return to its initial position as well.
An example of what I want can be seen at
http://www.iht.com look at the grey bar
almost on top of the page.
Hope someone is able to help out with this
T.I.A
André

RoyW
01-23-2003, 02:27 PM
<html>
<head>
<title>Floating Div</title>
</head>
<body bgColor="#000000">
<!--
* You may use this code for free on any web page provided that
* these comment lines and the following credit remain in the code.
* TopLeft Floating Div from http://www.javascript-fx.com
-->

<div id="divStayTopLeft" style="POSITION: absolute">
<table width="600" cellpadding=0 bgcolor="#777777" border=4>
<tr>
<td align="center">
HERE IS A STATIC LAYER<br>
PUT ANYTHING YOU LIKE IN BETWEEN THE &lt;div> tags
</td>
</tr>
</table>
</div>

<script type="text/javascript">
function JSFX_FloatTopLeft()
{
var startX = 25;
var startY = 200;

var ns = (navigator.appName.indexOf("Netscape") != -1);
var d = document;
function ml(id)
{
var el=d.getElementById?d.getElementById(id):d.all?d.all[id]:d.layers[id];
if(d.layers)el.style=el;
el.sP=function(x,y){this.style.left=x + "px";this.style.top=y + "px"};
el.x = startX; el.y = startY;
return el;
}
window.stayTopLeft=function()
{
var pY = ns ? pageYOffset : document.body.scrollTop;
ftlObj.y = (pY > startY) ? pY : startY;
ftlObj.sP(ftlObj.x, ftlObj.y);
setTimeout("stayTopLeft()", 20);
}
ftlObj = ml("divStayTopLeft");
stayTopLeft();
}
JSFX_FloatTopLeft();
</script>

<BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR>
<BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR>
<BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR>
<BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR>
<BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR>
<BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR>
<BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR>

</body>
</html>

andre73
01-23-2003, 03:15 PM
THANK YOU SO MUCH! YOU JUST SAVED MY DAY :thumbsup: