PDA

View Full Version : Floating Menu Script Help...



ideffect
12-29-2004, 06:31 PM
Hello,

I have a site http://www.thevortexbusinessinabox.com/content/view/13/40/ that i've been working on. I'm trying to get the floating menu to sit in the center of the page after it moves from the top. The floating menu sits in a frame that starts about 170px from the top. When looking from the very top, the bottom part of the menu is not visible. When scrolling down the page, that section of the menu is never visible. I'm hoping there's a way to adjust for that. I've tried a few diffrent ideas with no luck. The script's location is http://www.dynamicdrive.com/dynamicindex1/staticmenu.htm

I had to modify the script to work as it does now. I'm going to put the file below.

In the HTML


<script>
if (!document.layers)
document.write('<div id="divStayTopLeft" style="position:relative">')
</script>
<layer id="divStayTopLeft">
<?php mosLoadModules ( 'left' );?> <--Mambo Coding
</layer>


The script


//Enter "frombottom" or "fromtop"
var verticalpos="fromtop"

if (!document.layers)
document.write('</div>')

function JSFX_FloatTopDiv()
{
var startX = 0,
startY = 0;
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;this.style.top=y;};
el.x = startX;
if (verticalpos=="fromtop")
el.y = startY;
else{
el.y = ns ? pageYOffset + innerHeight : document.body.scrollTop + document.body.clientHeight;
el.y -= startY;
}
return el;
}
window.stayTopLeft=function()
{
if (verticalpos=="fromtop"){
var pY = ns ? pageYOffset : document.body.scrollTop;
ftlObj.y += (pY + startY - ftlObj.y)/70;
}
else{
var pY = ns ? pageYOffset + innerHeight : document.body.scrollTop + document.body.clientHeight;
ftlObj.y += (pY - startY - ftlObj.y)/30;
}
ftlObj.sP(ftlObj.x, ftlObj.y);
setTimeout("stayTopLeft()", 20);
}
ftlObj = ml("divStayTopLeft");
stayTopLeft();
}
JSFX_FloatTopDiv();


I really like this script but if you know of one that's better suited for what I am trying to do, please let me know.
Thank you for your help!