[Help] Jquery

smoochy boys on tour

Breezer

Mr Mañana
Legendary
Jul 16, 2004
3,370
539
315
Been messing around with some floating menu scripts using Jquery, which i managed to make work on my own website, but when i add another one below it (i want 4) the others stop moving?

http://www.stay-linked.co.uk

Thats one working, just not sure why when i add more that it stops moving (and the newest added still moves).

heres my Jquery script.

Code:
<script>if (!document.layers)
document.write('<div id="divStayTopLeft" style="position:absolute">')
</script>


<layer id="divStayTopLeft">


<table border="0" width="135" cellspacing="0" cellpadding="0">
  <tr>
    <td width="100%" style="background-image:url('http://www.stay-linked.co.uk/templates/joyfulgames/images/bar01.png')">
      <p align="center"><b><font size="4">Menu</font></b></td>
  </tr>
  <tr>
    <td width="100%" bgcolor="#cef1ff">
<?php include('./includes/modules/pages_vertical.php');?>    
<?php echo $template['pages_menu_seperator'].'<a href="'.$setting['site_url'].'/index.php?task=contact">Contact us</a>';?>
  </tr>
</table>
<!--END OF EDIT-->


</layer>




<script type="text/javascript">


var verticalpos="frombottom"


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


function JSFX_FloatTopDiv()
{
    var startX = 20,
    startY = 400;
    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)/8;
        }
        else{
        var pY = ns ? pageYOffset + innerHeight : document.body.scrollTop + document.body.clientHeight;
        ftlObj.y += (pY - startY - ftlObj.y)/8;
        }
        ftlObj.sP(ftlObj.x, ftlObj.y);
        setTimeout("stayTopLeft()", 10);
    }
    ftlObj = ml("divStayTopLeft");
    stayTopLeft();
}
JSFX_FloatTopDiv();
</script>

Anyone know what i've gotta do to get all 4 working ? Do i have to build them within the same script to ensure they don't roll over eachover and all move at the same time?
 

Celsius

LOMCN Veteran
Veteran
Dec 31, 2008
1,155
17
124
I'd attempt to help you, but I have no idea what you're on about?

Are you on about the menu that's on the left that follows you scrolling?

If so it has more than 4 menu items?

Confused.
 

Far

tsniffer
Staff member
Developer
May 19, 2003
20,172
30
2,767
540
do you want all 4 menus moving at the same time as each other? basically all under each other and moving in line with the page?

the bit which jscript tells to move is "divstaytopleft". So just simply duplicate the menu 4 times within this layer and it should do as you want. However, do you really need jscript for this? just have a fixed position on the div and it will always stay at the same position when you scroll.

http://www.w3.org/Style/Examples/007/menus.en.html

Also, your website needs a page title. It's not good for SEO without one.