Results 1 to 5 of 5

Thread: Need help with Floating Menu

  1. #1
    Join Date
    Apr 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Need help with Floating Menu

    1) Script Title: Floating Menu

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...staticmenu.htm

    3) Describe problem:
    Hi there. I am very new to javascript and wanted to get a webpage up quickly that used a floating menu so I am asking for help here.

    The script above has no problems when I view the URL in firefox, I see the menu and it floats perfectly.

    So, I followed the instructions and copied and pasted the code into my own page thinking it would be easy. But for some reason it does not work on my own page using the exact same browser (firefox).

    I am using dreamweaver to edit the page and was wondering if any could think of why this wouldn't work for me? Does the server the page resides on need something special? Do I need to identify the page as containing javascript in some way?

    Thanks for your help.
    -Julie

  2. #2
    Join Date
    Apr 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I keep thinking my problem might be something to do with layers.

    If I attempt to add a layer in Dreamweaver I notice it used "<div>" tags not "<layer>" tags.

    It also appears that the javascript itself seems to depend on layers. Is it possible there is some thing I need to do to enable layers using the "<layer>" tag on my webpage?

  3. #3
    Join Date
    Feb 2007
    Posts
    293
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Could you provide the URL of the page that you've done?

    Also, editors like Dreamweaver often make changes that mess up scripts. If you're copying and pasting a script/code, there should be some way in dreamweaver to do it using "html view." Sorry, I don't use Dreamweaver to know exactly where that is. But what you need to do is get into html view, and then paste the code and save it, all in html view.

    Finally, make sure you paste the code at the END of the document, right before the </body> tag

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Most likely it is because you have a DOCTYPE on your page and the demo page on DD does not.

    Try replacing this:

    Code:
    function JSFX_FloatTopDiv()
    {
    	var startX = 3,
    	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.sP(ftlObj.x, ftlObj.y);
    		setTimeout("stayTopLeft()", 10);
    	}
    	ftlObj = ml("divStayTopLeft");
    	stayTopLeft();
    }
    JSFX_FloatTopDiv();
    with this:

    Code:
    function ietruebody(){
    return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;
    }
    
    function JSFX_FloatTopDiv()
    {
    	var startX = 3,
    	startY = 150;
    	var PX='px', 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,PX='';}
    		el.sP=function(x,y){el.style.left=x+PX;el.style.top=y+PX;};
    		el.x = startX;
    		if (verticalpos=="fromtop")
    		el.y = startY;
    		else{
    		el.y = window.innerHeight ? pageYOffset + window.innerHeight : ietruebody().scrollTop + ietruebody().clientHeight;
    		el.y -= startY;
    		}
    		return el;
    	}
    	window.stayTopLeft=function()
    	{
    		if (verticalpos=="fromtop"){
    		var pY = window.innerHeight ? pageYOffset : ietruebody().scrollTop;
    		ftlObj.y += (pY + startY - ftlObj.y)/8;
    		}
    		else{
    		var pY = window.innerHeight ? pageYOffset + window.innerHeight : ietruebody().scrollTop + ietruebody().clientHeight;
    		ftlObj.y += (pY - startY - ftlObj.y)/8;
    		}
    		ftlObj.sP(ftlObj.x, ftlObj.y);
    		setTimeout("stayTopLeft()", 10);
    	}
    	ftlObj = ml("divStayTopLeft");
    	stayTopLeft();
    }
    JSFX_FloatTopDiv();
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  5. #5
    Join Date
    Apr 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks so much for the replies!

    I was using html view but I did have a doctype:

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

    However, I managed to find another website that had a floating menu that specified I create a <div> section instead of a <layer> section and this one worked even with the doctype.

    Now that I've got it working I don't want to mess with it! But I'll definitely keep these thoughts in mind for next time.

    Thanks again! I was really starting to panic there for a bit.

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
  •