Results 1 to 9 of 9

Thread: floating menu goes too far down

  1. #1
    Join Date
    Jun 2008
    Posts
    192
    Thanks
    9
    Thanked 0 Times in 0 Posts

    Default floating menu goes too far down

    1) Script Title:

    Floating Menu script

    2) Script URL (on DD):

    http://www.shahspace.com/mm-theory/home.htm

    3) Describe problem:

    Hello,

    I'm trying to program a Floating Menu script into my website here. I did it exactly as the instructions say: I copied and pasted the whole code provided and just before my </body> tag. It seems to work in that it keeps the menu at the bottom of my page but it's literally at the bottom of the page - i.e. it's WAY below the bottom of the screen and you have to scroll WAY down to see it. How can I program it to hover at the bottom of the screen rather than the entire page? Or better yet, how do I get it to hover near the middle or near the top? How can I set the precise location?

    Thanks for the forthcoming help.

  2. #2
    Join Date
    Feb 2008
    Location
    Cebu City Philippines
    Posts
    1,160
    Thanks
    17
    Thanked 277 Times in 275 Posts

    Default

    See if removing the DTD helps.
    Learn how to code at 02geek

    The more you learn, the more you'll realize there's much more to learn
    Ray.ph!

  3. #3
    Join Date
    Feb 2008
    Location
    Cebu City Philippines
    Posts
    1,160
    Thanks
    17
    Thanked 277 Times in 275 Posts

    Default

    Floating menu script never works when there is a DTD.
    Hopefully, this new edition should work with DTD:
    Code:
    <script>
    if (!document.layers)
    document.write('<div id="divStayTopLeft" style="position:absolute">')
    </script>
    
    <layer id="divStayTopLeft">
    
    <!--EDIT BELOW CODE TO YOUR OWN MENU-->
    <table border="1px" width="130px" cellspacing="0" cellpadding="0">
      <tr>
        <td width="100%" bgcolor="#FFFFCC">
          <p align="center"><b><font size="4px">Menu</font></b></td>
      </tr>
      <tr>
        <td width="100%" bgcolor="#FFFFFF">
          <p align="left"> <a href="http://www.dynamicdrive.com">Dynamic Drive</a><br>
           <a href="http://www.dynamicdrive.com/new.htm">What's New</a><br>
           <a href="http://www.dynamicdrive.com/hot.htm">What's Hot</a><br>
           <a href="http://www.dynamicdrive.com/faqs.htm">FAQs</a><br>
           <a href="http://www.dynamicdrive.com/morezone/">More Zone</a></td>
      </tr>
    </table>
    <!--END OF EDIT-->
    
    </layer>
    
    
    <script type="text/javascript">
    
    /*
    Floating Menu script-  Roy Whittle (http://www.javascript-fx.com/)
    Script featured on/available at http://www.dynamicdrive.com/
    This notice must stay intact for use
    */
    
    //Enter "frombottom" or "fromtop"
    var verticalpos="frombottom"
    
    if (!document.layers)
    document.write('</div>')
    
    function JSFX_FloatTopDiv()
    {
    	var startX = 3,
    	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;
    		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>
    Hope it helps.
    Learn how to code at 02geek

    The more you learn, the more you'll realize there's much more to learn
    Ray.ph!

  4. #4
    Join Date
    Jun 2008
    Posts
    192
    Thanks
    9
    Thanked 0 Times in 0 Posts

    Default

    You're right! Commenting out the DTD solved the problem... but it created a different problem. Now my webpage is all messed up. The main content has completely disappeared.

    My DTD looks like this:

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

    Is there something I can replace it with that'll work with my floating menu?

  5. #5
    Join Date
    Feb 2008
    Location
    Cebu City Philippines
    Posts
    1,160
    Thanks
    17
    Thanked 277 Times in 275 Posts

    Default

    Have you had tried to play with the script I posted in post#3? It should work with DTD.
    Learn how to code at 02geek

    The more you learn, the more you'll realize there's much more to learn
    Ray.ph!

  6. #6
    Join Date
    Jun 2008
    Posts
    192
    Thanks
    9
    Thanked 0 Times in 0 Posts

    Default

    I sure did. I tried it with my DTD and without it. It only works without it.

  7. #7
    Join Date
    Feb 2008
    Location
    Cebu City Philippines
    Posts
    1,160
    Thanks
    17
    Thanked 277 Times in 275 Posts

    Default

    You're not updating your page. And, if you will, I could'nt get in since its blocked (just now) in my workplace.

    Have you tried adding the highlighted into the script:
    Code:
    el.sP=function(x,y){this.style.left=x+'px';this.style.top=y+'px';};
    Learn how to code at 02geek

    The more you learn, the more you'll realize there's much more to learn
    Ray.ph!

  8. #8
    Join Date
    Jun 2008
    Posts
    192
    Thanks
    9
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by rangana View Post
    You're not updating your page. And, if you will, I could'nt get in since its blocked (just now) in my workplace.
    No I haven't updated the code on the server. I have no access to it right now. I'm updating it on my laptop. I probably won't be able to update the server until after the weekend unless I make a stop at the office sooner.

    Quote Originally Posted by rangana View Post
    Have you tried adding the highlighted into the script:
    Code:
    el.sP=function(x,y){this.style.left=x+'px';this.style.top=y+'px';};
    Yes, that line is already there - even the highlighted parts.

    I appreciate the help. Any other suggestions (like a substitute for the DTD)?

  9. #9
    Join Date
    Jun 2008
    Posts
    192
    Thanks
    9
    Thanked 0 Times in 0 Posts

    Default

    I've updated the website.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •