Web Analytics Made Easy -
StatCounter can't figure out how to center scrollable menu! - CodingForum

Announcement

Collapse
No announcement yet.

can't figure out how to center scrollable menu!

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • can't figure out how to center scrollable menu!

    I'm using the scrollable menu links code and it works great. Or at least it will once I put up the pages for the links to go to! But it's shoved to the left and I can't figure out how to get it centered!

    Regular html code isn't working. Help!

    here's the code, the only thing different on my site is the images and links.

    <style>
    body{
    overflow-x:hidden;
    overflow-y:scroll;
    }
    </style>

    <script language="JavaScript1.2">

    /*
    Scrollable Menu Links- By Dynamicdrive.com
    For full source, TOS, and 100s DTHML scripts
    Visit http://dynamicdrive.com
    */

    //configure path for left and right arrows
    var goleftimage='pointer2.gif'
    var gorightimage='pointer.gif'
    //configure menu width
    var menuwidth=300
    //configure scroll speed (1-10), where larger is faster
    var scrollspeed=6
    //specify menu content
    var menucontents='<nobr><a href="http://www.dynamicdrive.com">Dynamic Drive</a> | <a href="http://wsabstract.com">Website Abstraction</a> | <a href="http://www.codearena.com">CodeArena.com</a> | <a href="http://www.builder.com">Builder.com</a> | <a href="http://freewarejava.com">Freewarejava.com</a></nobr>'


    ////NO NEED TO EDIT BELOW THIS LINE////////////

    var actualwidth=''
    var ns_scroll
    function fillup(){
    if (document.all){
    test2.innerHTML=menucontents
    actualwidth=test2.offsetWidth
    }
    else if (document.layers){
    ns_scroll=document.ns_scrollmenu.document.ns_scrollmenu2
    ns_scroll.document.write(menucontents)
    ns_scroll.document.close()
    actualwidth=ns_scroll.document.width
    }
    }
    window.onload=fillup

    function moveleft(){
    if (document.all&&test2.style.pixelLeft>(menuwidth-actualwidth))
    test2.style.pixelLeft-=scrollspeed
    else if (document.layers&&ns_scroll.left>(menuwidth-actualwidth))
    ns_scroll.left-=scrollspeed
    lefttime=setTimeout("moveleft()",50)
    }

    function moveright(){
    if (document.all&&test2.style.pixelLeft<0)
    test2.style.pixelLeft+=scrollspeed
    else if (document.layers&&ns_scroll.left<0)
    ns_scroll.left+=scrollspeed
    righttime=setTimeout("moveright()",50)
    }

    if (document.all||document.layers){
    with (document){
    write('<table border="0" cellspacing="0" cellpadding="0">')
    write('<td valign="middle"><a href=#" onMouseover="moveleft()" onMouseout="clearTimeout(lefttime)"><img src="'+goleftimage+'"border=0></a>&nbsp;</td>')
    write('<td valign="top">')
    if (document.all){
    write('<span style="position:relative;width:'+menuwidth+';">')
    write('<span style="position:absolute;width:'+menuwidth+';clip:rect(0 '+menuwidth+' auto 0)">')
    write('<span id="test2" style="position:absolute;left:0;top:0">')
    write('</span></span></span>')
    }
    else if (document.layers){
    write('<ilayer width='+menuwidth+' name="ns_scrollmenu">')
    write('<layer name="ns_scrollmenu2" left=0 top=0></layer></ilayer>')
    }
    write('</td>')
    write('<td valign="middle">&nbsp;<a href="#" onMouseover="moveright()" onMouseout="clearTimeout(righttime)">')
    write('<img src="'+gorightimage+'"border=0></a>')
    write('</td></table>')
    }
    }
    </script>

  • #2
    Next time, you can simply put in the link to the script's actual page instead of pasting your code. For example, http://www.dynamicdrive.com/dynamici...rollerlink.htm.

    It would also be preferrable to have a link to YOUR web page so that we may see how/where you're wanting to place the script.

    Based on what you've given, I have to following two options to suggest.

    #1 -- put the script inbetween a <div align="center"> and </div>

    #2 -- use a table (centered) ... center a middle cell, center the entire table, etc....whatever works for you.

    Again, if you're unable to get one of these options to work for you, give us your web page URL so that we may assist you further.

    Good luck.
    Gordo
    "In the End, we will remember not the words of our enemies, but the silence of our friends."
    - Martin Luther King Jr. (1929-1968)

    Comment


    • #3
      Thanks! That did it. I had to figure out where to put the tags but luckily that silver box is only too happy to pop up and tell what line is screwed up.

      I didn't put a url because I didn't have it on my page. At the time it was still under construction and it still is actually. I've uploaded it to a test page so you can see it, but only the link to Current Contest works so far.




      Thanks again for your help!

      Comment

      Working...
      X