Major Problems with menuwidth="100%"

Having problems with DHTML Menu? There is usually somebody here who knows the answer.
halcyon
Advanced
Advanced
Posts: 22
Joined: Wed Oct 08, 2003 9:43 pm
Contact:

Major Problems with menuwidth="100%"

Post by halcyon »

Hi just wanted to report the problem I'm having. Currently using my menu in a 100% width table at the top of my page. The menu code is as follows:

Code: Select all

				
with(milonic=new menuname("Marketing")){
	alwaysvisible=1;
	left="0";
	menuwidth="100%";
	orientation="horizontal";
	position="relative";
	style=menuStyle;
aI("text=Home Page;url=/home.do;status=Back To Home Page;");
aI("text=View/Print Materials;url=/productSpecs/materials.jsp;");
aI("text=View/Print References;url=/flexReferences/viewFlexReferencesQuery.do;");
aI("text=Manage Prospects;url=/marketing/viewProspects.do;");
aI("text=Manage Sales Regions;url=/marketing/viewSalesRegions.do;");
}
The menu on a refresh takes up the entire top of the screen just fine, but if I try to resize my browser it stays solid at that width regardless of my resizing. Is this possible to be fixed? It would be ideal if the menu's resized with the browser when set to 100% width, or any % width in my opinion.

Thanks for a great product,
David
Last edited by halcyon on Thu Jan 08, 2004 10:20 pm, edited 4 times in total.
halcyon
Advanced
Advanced
Posts: 22
Joined: Wed Oct 08, 2003 9:43 pm
Contact:

Post by halcyon »

In addition to the above problem I've also noticed that randomly when I first hit a URL with the menu sometimes it will open the menu only like around 300 pixels wide, each item is just wide enuf to fill one of the words. IE if the menu item was "Product Info" that item would only be wide enough for Product and kick info down to the next line. Very strange.

Here are some pics to illustrate what I'm talking about.
First load of the page:

Image

After hitting refresh it goes like it should:
Image

What could be the problem?
-David
halcyon
Advanced
Advanced
Posts: 22
Joined: Wed Oct 08, 2003 9:43 pm
Contact:

Post by halcyon »

Any ideas? :)
User avatar
Maz
Milonic God
Milonic God
Posts: 1717
Joined: Fri Jun 06, 2003 11:39 pm
Location: San Francisco
Contact:

Post by Maz »

Use the space character between words

& n b s p ;

without spaces between, thats so you can see the space here.
maz
halcyon
Advanced
Advanced
Posts: 22
Joined: Wed Oct 08, 2003 9:43 pm
Contact:

Post by halcyon »

Thanks maz, that solved them bunching up all together, however the random problem of the menu not taking up the full width still exists, along with resizing not working. Here is a pic of what is randomly happening now still:

Image

the gray background shows that the table cell the menu is in IS taking up 100% of the width..
halcyon
Advanced
Advanced
Posts: 22
Joined: Wed Oct 08, 2003 9:43 pm
Contact:

Post by halcyon »

I'm going to go ahead and post some source to this so you can reproduce it on your own, links will need to be modified of course for wherever you have your scripts located on the machine you look at this on. The problems demonstrated with this code are:
1) Randomly the menu at the top won't fill the full width, it seems less severe with this code snippet, but you will definitly randomly see a gap on the right side (tested on IE6)
2) Resizing the browser does nothing to resize the menu, it stays static.

Code: Select all

<html>
	<head><title>Blah</title></head>
	<body cellspacing="0" cellpadding="0" marginheight="0" marginwidth="0" leftmargin="0" topmargin="0">
  		<table  cellpadding="0" cellspacing="0" align="left" valign="top" width="100% ">
			<tbody>
				<tr width="100%">	
					<td valign="top" align="left" width="100%">
						





<table width="100%" cellpadding="0" cellspacing="0" border="0">
    <tr>
        <td align="left" valign="top" width="100%" bgcolor="#BBBBBB">
			<link rel="stylesheet" type="text/css" media="screen" href="/tiles/styles/menu.css" /> 
			    
	
        	
	
			<SCRIPT language=JavaScript src="/tiles/scripts/milonic_src.js" type=text/javascript></SCRIPT>	
			<script	language=JavaScript>
			if(ns4)_d.write("<scr"+"ipt language=JavaScript src=/tiles/scripts/mmenuns4.js><\/scr"+"ipt>");		
			  else _d.write("<scr"+"ipt language=JavaScript src=/tiles/scripts/mmenudom.js><\/scr"+"ipt>"); 
			</script>
                        
            
            <script language=JavaScript type=text/javascript>
                _menuCloseDelay=400; 
_menuOpenDelay=150;
_followSpeed=5;
_followRate=50;
_subOffsetTop=5;
_subOffsetLeft=-10;
_scrollAmount=3;
_scrollDelay=20;



with(menuStyle=new mm_style()){
onbgcolor="#323299";
oncolor="#ffffff";
offbgcolor="#000066";
offcolor="#ffffff";
bordercolor="#323299";
borderstyle="solid";
borderwidth=0;
separatorcolor="#323299";
separatorsize="1";
padding=5;
fontsize="75%";
fontstyle="normal";
fontfamily="Arial, Times New Roman, Verdana, Tahoma";
fontweight="bold";
pagecolor="#323299";
pagebgcolor="#82B6D7";
headercolor="#000000";
headerbgcolor="#ffffff";
subimage="/images/arrow.gif";
subimagepadding="2";
overfilter="Fade(duration=0.2);Alpha(opacity=100)";
outfilter="randomdissolve(duration=0.3)";
}

with(menuStyle2=new mm_style()){
onbgcolor="#323299";
oncolor="#ffffff";
offbgcolor="#000066";
offcolor="#ffffff";
bordercolor="#323299";
borderstyle="solid";
borderwidth=1;
separatorcolor="#323299";
separatorsize="1";
padding=5;
fontsize="75%";
fontstyle="normal";
fontfamily="Arial, Times New Roman, Verdana, Tahoma";
fontweight="bold";
pagecolor="#323299";
pagebgcolor="#82B6D7";
headercolor="#000000";
headerbgcolor="#ffffff";
subimage="/images/arrow.gif";
subimagepadding="2";
overfilter="Fade(duration=0.2);Alpha(opacity=100);Shadow(color='#777777', Direction=135, Strength=5)";
outfilter="randomdissolve(duration=0.3)";
}
            </script>
			
<script type="text/javascript">
<!--

				
with(milonic=new menuname("Marketing")){
	alwaysvisible=1;
	itemwidth="100%";
	menualign="center";
	menuwidth="100%";
	orientation="horizontal";
	position="relative";
	style=menuStyle;
aI("text=Home&nbsp;Page;url=/home.do;status=Back To Home Page;align=center;");
aI("text=View/Print&nbsp;Materials;url=/productSpecs/materials.jsp;align=center;");
aI("text=View/Print&nbsp;References;url=/flexReferences/viewFlexReferencesQuery.do;align=center;");
aI("text=Manage&nbsp;Prospects;url=/marketing/viewProspects.do;align=center;");
aI("text=Manage&nbsp;Sales&nbsp;Regions;url=/marketing/viewSalesRegions.do;align=center;");
}


				    
				
			

drawMenus();
//-->
</script>

        </td>
	</tr>
</table>
					</td>
				</tr>
			</tbody>
		</table>			
   	</body>
</html>
halcyon
Advanced
Advanced
Posts: 22
Joined: Wed Oct 08, 2003 9:43 pm
Contact:

Post by halcyon »

FYI this problem does not seem to appear in Netscape 7.1.
Any updates from the mods?
-David
User avatar
Maz
Milonic God
Milonic God
Posts: 1717
Joined: Fri Jun 06, 2003 11:39 pm
Location: San Francisco
Contact:

Post by Maz »

I'll attempt this;)

Try putting the scripts just below body, taking them out of the table.

I'm puzzled because I see menustyle1 & 2 but only see menustyle1 referenced.

There are 2 ways of placing a menu in a table.

One is where you only put the menu-data.js script in the <td>, I like that one because its easier.

The other where you place most of menu-data.js after the other scripts under body, but take out the items and place those in the td.

BTW on Mac IE I cannot get 100% centered, it stays on the left.

Regards,
maz
halcyon
Advanced
Advanced
Posts: 22
Joined: Wed Oct 08, 2003 9:43 pm
Contact:

Post by halcyon »

I tried moving the scripts up and out of the table and only putting the items in the td and I'm still having trouble..

What I've found is the horizontal menu function works fantastic when its not set to relative positioning, it takes up the full screen, resizes etc. However when set to relative positioning I've had it flakily take up different widths of the screen, and it does not resize at all when the browser window is resized.

Frankly I'm surprised I haven't had any comments from the admins in this thread... surely they are aware of these problems?
-David
User avatar
Maz
Milonic God
Milonic God
Posts: 1717
Joined: Fri Jun 06, 2003 11:39 pm
Location: San Francisco
Contact:

Post by Maz »

Is there any reason why you can't place the menu on top?

Take a look at my -www- link. The menu is more stable absolutely positioned from the top. Before that I used the whole data script <script...menu_data.js ...></scrpt> in the table, but the more I tried to do with the menu the more problems I ran into, there are browser differences and compatibility issues inside css.

Regards,
maz
User avatar
kevin3442
Milonic God
Milonic God
Posts: 2460
Joined: Sat Sep 07, 2002 12:09 am
Location: Lincoln, NE
Contact:

Post by kevin3442 »

Hi David,
halcyon wrote:...Frankly I'm surprised I haven't had any comments from the admins in this thread... surely they are aware of these problems?
Well, speaking for myself, (1) I have been reading the thread, but (2) I have not contributed because I thought Maz's suggestions were quite good, (3) I had nothing to add as a definitive solution, and (4) I am not aware of this particular problem as a known issue with a known solution. Personally, I have never encountered this problem in my own use of the menu, nor have I seen these paricular problems discussed in other threads. I am aware, however, of various strange behaviors people have encountered when trying to bind the menus to tables. I think that's what you have here... a uniquely odd behavior that results from putting the menu code in a unique table structure.

The sample page (sample 9) that discusses how to embed a menu in a table, notes the following:
Note that this feature is still a work in progress and issues with tables [sic... should be 'menus'] embedded within tables are still evident, we are working on this though. If you are experiencing problems with relative menu positioning however, try and embed only the menu you want to be included within the table cell. Embedding whole menus is possible but can cause unpredictable results in complex table structures.
The sample code you provided does indeed embed all of your menu code, as well as all of the Milonic code, inside a somewhat complex table structure (in a table within a table). I'd say that the problems you are experienceing qualify as "unpredictable results". Many browers don't like it when you put javascript in a table, especialy if there's a lot of it. You might try as the sample suggests: (1) place your calls to milonic_src.js, mmenudom.js, (and mmenuns4.js) in the <head> or (as Maz suggests) at the top of the <body>, outside of any table definition. (2) place all of your menu code, except the main menu definition, inside a menu_data.js file, that you also src into the html page (where you load the other .js files). (3) Put only the code for your main menu in the table cell, along with the call drawMenus(), as shown on the sample page.

You may find that, with your combination of positioning in the table cell, combined with the table's own positioning, that you still have problems. have you considered not placing the manu in a table at all? (I think this is what Maz was getting at with her last suggestion). I believe that it would be pretty straight forward to achieve your desired page layout using the menu system's built-in positioning capabilities, without having to put the menu in a table. No embedding in tables... no odd table-related problems! Here's what your menu_data.js file might contain:

Code: Select all

_menuCloseDelay=400;
_menuOpenDelay=150;
_followSpeed=5;
_followRate=50;
_subOffsetTop=5;
_subOffsetLeft=-10;
_scrollAmount=3;
_scrollDelay=20;

with(menuStyle=new mm_style()){
onbgcolor="#323299";
oncolor="#ffffff";
offbgcolor="#000066";
offcolor="#ffffff";
bordercolor="#323299";
borderstyle="solid";
borderwidth=0;
separatorcolor="#323299";
separatorsize="1";
padding=5;
fontsize="75%";
fontstyle="normal";
fontfamily="Arial, Times New Roman, Verdana, Tahoma";
fontweight="bold";
pagecolor="#323299";
pagebgcolor="#82B6D7";
headercolor="#000000";
headerbgcolor="#ffffff";
subimage="/images/arrow.gif";
subimagepadding="2";
overfilter="Fade(duration=0.2);Alpha(opacity=100)";
outfilter="randomdissolve(duration=0.3)";
align="center";
}

with(milonic=new menuname("Marketing")){
top=0;
left=0;
//screenposition="center";
//menualign="center";
//menuwidth="100%";
alwaysvisible=1;
itemwidth="100%";
orientation="horizontal";
style=menuStyle;
aI("text=Home Page;url=/home.do;status=Back To Home Page;");
aI("text=View/Print Materials;url=/productSpecs/materials.jsp;");
aI("text=View/Print References;url=/flexReferences/viewFlexReferencesQuery.do;");
aI("text=Manage Prospects;url=/marketing/viewProspects.do;");
aI("text=Manage Sales Regions;url=/marketing/viewSalesRegions.do;");
}

drawMenus();
This would be in menu_data.js, loaded into your html file in the <head>, using the standard recommended method, like so:

Code: Select all

<script language=JavaScript src="milonic_src.js" type=text/javascript></script>
<script	language=JavaScript>
if(ns4)_d.write("<scr"+"ipt language=JavaScript src=mmenuns4.js><\/scr"+"ipt>");
  else _d.write("<scr"+"ipt language=JavaScript src=mmenudom.js><\/scr"+"ipt>");
</script>
<script language=JavaScript src="menu_data.js" type=text/javascript></script>
Note that in the menu_data.js file:

(1) Got rid of menuStyle2, since it wasn't used in your sample

(2) Put align="center"; in menuStyle, and removed it from each menu item definition... less coding that way.

(3) Set the menu properties in the "Marketing" menu to achive the effect I think you're looking for. You'll notice that the screenposition, menualign, and menuwidth properties are currently commented out. I don't think you'll need these properties to get the look you want, but you may end up having to play with them some as you check across browsers.

(4) Removed the non-breaking spaces in the menu items' text, so that if the menu gets squeezed, it can wrap the words and continue to shrink.

One more general suggestion. It looks like you're loading your menu.css file in the same table cell where you're loading the menu scripts. Might be better to load your style sheets in the <head>, and outside of any table.

Hope that helps,

Kevin
halcyon
Advanced
Advanced
Posts: 22
Joined: Wed Oct 08, 2003 9:43 pm
Contact:

Post by halcyon »

Thanks for the suggestions maz and kevin, ya I have thought about using the menu absolutely positioned but I really would rather avoid that if possible because as far as I am aware you never actually know how tall your menu is. Suppose I lay it out as you suggested, the menu could be 100 pixels high or could be 200 if they squished all the text together, and that would overlap over content below it. Is there anyway to tackle that problem?

Also I would be more interested in knowing how I could embed each menu item within a table cell instead of the whole menu in a cell as well, perhaps that could solve the problem.
Thanks
-David
User avatar
Maz
Milonic God
Milonic God
Posts: 1717
Joined: Fri Jun 06, 2003 11:39 pm
Location: San Francisco
Contact:

Post by Maz »

I haven't personally done the linking to items in a table. I remember it being tallked about and I'm sure there is a post if you know what topic to search for in the forum.

Someone else might be able to give you a few pointeers.

Regards,
maz
User avatar
John
 Team
 Team
Posts: 5967
Joined: Sun May 19, 2002 8:23 pm
Location: Phoenix, AZ
Contact:

Post by John »

halcyon wrote:Also I would be more interested in knowing how I could embed each menu item within a table cell instead of the whole menu in a cell as well, perhaps that could solve the problem.
Very easily...

Put the menu code calls as the first items directly after <body>...

Code: Select all

<script language="JavaScript" src="/tiles/scripts/milonic_src.js" type="text/javascript"></script>    
<script language="JavaScript"> 
if(ns4)_d.write("<scr"+"ipt language=JavaScript src=/tiles/scripts/mmenuns4.js><\/scr"+"ipt>");       
else _d.write("<scr"+"ipt language=JavaScript src=/tiles/scripts/mmenudom.js><\/scr"+"ipt>"); 
</script>
In the <td> where you want your menu, put only the call to the data file (although it is sometimes possible to have other items in the same <td>)...

Code: Select all

<script language="JavaScript" src="/tiles/scripts/menu_data.js" type="text/javascript"></script>
John
halcyon
Advanced
Advanced
Posts: 22
Joined: Wed Oct 08, 2003 9:43 pm
Contact:

Post by halcyon »

John: Ya that is exactly what I've got. the page the menu is in is actually far more complex than the code I listed, but I pulled all my scripting code except for the actual menu data itself up to the <head> tag, and placed only the menu data code inside the td in a <script> tag. The problem is still there but more intermittent, I also moved the table its in to the top so its only nested inside one table on the page.

Is there someway I can debug this javascript? IE set breakpoints and watch what is happening? I would love to be able to help solve whatever is causing this for me and for everyone else.. my page loads fine in Netscape and never causes the menu to not fill the full width, and 90% of the time its fine in IE6 too, but those other times are very annoying, and I'd love to help if I can (fellow coder).

-David
User avatar
John
 Team
 Team
Posts: 5967
Joined: Sun May 19, 2002 8:23 pm
Location: Phoenix, AZ
Contact:

Post by John »

halcyon wrote:...I pulled all my scripting code except for the actual menu data itself up to the <head> tag...
Try it where I mentioned, as first in <body>. Shouldn't make a difference, but sometimes we find it does.
halcyon wrote:Is there someway I can debug this javascript?
You are certainly welcome to fiddle with it as a coder (both Dave and Kevin are JS 'nuts'). However, please do not post any code 'fixes' here in the Forum. We'll get you directly to Andy if you come up with something.
John
halcyon
Advanced
Advanced
Posts: 22
Joined: Wed Oct 08, 2003 9:43 pm
Contact:

Post by halcyon »

On another vein though, are we going to see the functionality of the menu being able to be resized inside of a table (relative)? IE I shrink/enlarge my browser window and the menu resizes appropriaetly? I know that works currently with absolute, but would be great for relative.

-David
Last edited by halcyon on Wed Jan 14, 2004 9:35 pm, edited 1 time in total.
User avatar
kevin3442
Milonic God
Milonic God
Posts: 2460
Joined: Sat Sep 07, 2002 12:09 am
Location: Lincoln, NE
Contact:

Post by kevin3442 »

Hi David,

Well... I just wrote a long and insightful reply, but I was too long on the page and I guess my login timed out. So, when I went to preview it, I had to log in again and everything I typed was gone :!: Man I hate it when that happens! :x I usually copy everything to the clipboard before previewing a long post, for just such an occasion, but forgot to do it that time. Now I'll have to do it over, but no time right now unfortunately. Hopefully, later.

For now, how 'bout this: what happens if you comment out the position="relative"; line in the code within the table? You might also try position="float"; and see if that gets the job done.

Kevin
User avatar
Maz
Milonic God
Milonic God
Posts: 1717
Joined: Fri Jun 06, 2003 11:39 pm
Location: San Francisco
Contact:

Post by Maz »

http://www.w3.org/TR/html401/struct/tab ... h-11.3.2.1

This link may be useful, I think its the th that controls the full width, centered, justified, bold.

My css (no tables) site is liquid, I never use relative and almost no positioning, width 100%.

I'm more interested in applying the scope tag, if the outside table header could scope row & column of the js table, then we would have access, but knowing my luck it doesn't work like that.

Regards,
maz
halcyon
Advanced
Advanced
Posts: 22
Joined: Wed Oct 08, 2003 9:43 pm
Contact:

Post by halcyon »

Kevin: I tried position=float; That ironically as far as I have been able to test fixed the width problem, but introduced a new problem, mousing over and clicking does not do anything =) What is the behavior of float supposed to do?

with position not specified, at its default absolute, it sits over the top of my page and works, except my page is skewed because I don't know how tall the menu is exactly so it covers up the top section of my page, that was the whole reason to have it in a table, so I can know exactly where to begin the rest of my page.
-David
Post Reply