Results 1 to 7 of 7

Thread: "Floating Menu Script" mod

  1. #1
    Join Date
    Oct 2004
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default "Floating Menu Script" mod

    This is a simple fix for you javascript gurus! (not for me though!)

    The script in question is located here: http://www.dynamicdrive.com/dynamici...staticmenu.htm

    All I want is instead of having the script floating on only the left side, could you modify the script so the menu floats on the right bottom?

    Also I would prefer if the location of the menu could be user specified by position, but that is a secondary request!

    Thanks in advance!

  2. #2
    Join Date
    Oct 2004
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Just want to know if this is an easy fix...
    Please some response would be appreciated!

  3. #3
    Join Date
    Oct 2004
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hi.

    Look for this line of code:

    var startX = 5,
    startY = 180;

    ---

    alter those values a bit for testing and see what you get.

    Take care...

  4. #4
    Join Date
    Oct 2004
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    yeah but those are absolute values...

  5. #5
    Join Date
    Aug 2004
    Location
    Brighton
    Posts
    1,563
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I've modified the script for you, but I've only checked it in Firefox (I'm very pushed for time at the moment), so test it and report back to me.

    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="1" width="130" cellspacing="0" cellpadding="0">
      <tr>
        <td width="100%" bgcolor="#FFFFCC">
          <p align="center"><b><font size="4">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
    Modified 25th October 2004 by cr3ative @ dynamicdrive.com/forums to stay in right-hand side of window.
    */
    
    //Enter "frombottom" or "fromtop"
    var verticalpos="frombottom"
    
    if (!document.layers)
    document.write('</div>')
    
    function JSFX_FloatTopDiv()
    {
    	var startX = document.body.clientWidth - 150,
    	startY = 150;
    	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.x = document.body.clientWidth - 150;
    		}
    		ftlObj.sP(ftlObj.x, ftlObj.y);
    		setTimeout("stayTopLeft()", 10);
    	}
    	ftlObj = ml("divStayTopLeft");
    	stayTopLeft();
    }
    JSFX_FloatTopDiv();
    </script>


    Code Notes: Wherever you see:

    var startX = document.body.clientWidth - 150,
    or
    ftlObj.x = document.body.clientWidth - 150;

    Then 150 needs to be made larger if you have a wider menu.

    cr3ative
    Last edited by cr3ative; 10-25-2004 at 05:59 PM.
    A retired member, drop me a line through my site if you'd like to find me!
    cr3ative media | read the stickies

  6. #6
    Join Date
    Oct 2004
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    the code works...

    however remove the spaces in the following lines:

    var el=d.getElementById?d.getElementById(id):d.all?d.a ll[id]:d.layers[id];
    el.sP=function(x,y){this.style.left=x;this.style.t op=y;};

    thanks a lot creative!

  7. #7
    Join Date
    Aug 2004
    Location
    Brighton
    Posts
    1,563
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Well spotted

    It doesn't want to edit them out using the Edit button, so I guess my old post'll have to live with them

    cr3ative
    A retired member, drop me a line through my site if you'd like to find me!
    cr3ative media | read the stickies

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
  •