Se avete qualche minuto da perdere vi incollo questo script e vi chiedo come mai se lo allineo a destra dentro la cella di una tabella quando apro la pagina (la tabella è width 100%) mi lascia un margine a destra oltre la tabella, se passo sopra a 'contatti' torna a posto.Se capite il perchè mi dite come si può fare (lo script è garantito crossbrowsers, almeno dicono). Grazie mille - ciao
<script type="text/javascript" language="JavaScript">
<!---
// VOCI MENU
var Menu1 = new Array ()
var subMenu1 = new Array ()
Menu1[0] = new Array("home", "index.html","_top", "left")
subMenu1[0] = new Array()
Menu1[1] = new Array("internet", "","_top", "left")
subMenu1[1] = new Array()
subMenu1[1][0] = new Array ("siti", "siti.html","_top")
subMenu1[1][1] = new Array ("news", "news.html","_top")
subMenu1[1][2] = new Array ("audio", "audio.html","_top")
subMenu1[1][3] = new Array ("animazioni", "animazioni.html","_top")
Menu1[2] = new Array("downloads", "download.html","_top", "left")
subMenu1[2] = new Array()
Menu1[3] = new Array("about us", "aboutus.html","_top", "left")
subMenu1[3] = new Array()
Menu1[4] = new Array("contatti", "contatti.html","_top", "left")
subMenu1[4] = new Array()
Menu1[5] = new Array("link", "link.html","_top", "left")
subMenu1[5] = new Array()
// FORMAT MENU
menuStyle = "3d"
cellPadding = 2
cellBorder = 1
verticalOffset = 0
horizontalOffset = 0
subMenuDelay = 1
subIndicate = 1
indicator = "[img]images/opened.gif[/img]"
// Main Menu Items
borderColor = "white"
borderHighlight = "#993333"
borderShadow = "#cc3366"
menuBackground = "#cc3300"
menuHoverBackground = "beige"
fontFace = "verdana"
fontColour = "#FFFFFF"
fontHoverColour = "#2b83c4"
fontSize = "11px"
fontDecoration = "none"
fontWeight = "normal"
// Sub Menu Items
sborderColor = "Black"
sborderHighlight = "#993333"
sborderShadow = "#cc3366"
smenuBackground = "#cc3300"
smenuHoverBackground = "beige"
sfontFace = "arial"
sfontColour = "#FFFFFF"
sfontHoverColour = "#2b83c4"
sfontSize = "11px"
sfontDecoration = "none"
sfontWeight = "normal"
sShadow = 1
// END FORMAT MENU
quantity = 1
// Browser Sniffer
var isIE = (document.getElementById && document.all)?true:false;
var isNS4 = (document.layers)?true:false;
var isNS6 = (document.getElementById && !document.all)?true:false;
var timer;
var obj = (isIE)?"document.all":"document.getElementById"
styleBorder=(menuStyle.toLowerCase() == "flat")?cellBorder:0
// Menu Styles
document.writeln ('<style>');
document.writeln ('.rcMenuStatic {font-family:'+fontFace+';font-size:'+fontSize+';color:'+fontColour+';font-weight:'+fontWeight+';background-color:'+menuBackground+'; cursor:hand; text-decoration:'+fontDecoration+'}');
document.writeln ('.rcMenuHover {font-family:'+fontFace+';font-size:'+fontSize+';color:'+fontHoverColour+';font-weight:'+fontWeight+';background-color:'+menuHoverBackground+'; cursor:hand; text-decoration:'+fontDecoration+'}');
document.writeln ('.rcSubMenuStatic {font-family:'+sfontFace+';font-size:'+sfontSize+';color:'+sfontColour+';font-weight:'+sfontWeight+';text-decoration:'+sfontDecoration+';background-color:'+smenuBackground+'; cursor:hand}');
document.writeln ('.rcSubMenuHover {font-family:'+sfontFace+';font-size:'+sfontSize+';color:'+sfontHoverColour+';font-weight:'+sfontWeight+';text-decoration:'+sfontDecoration+';background-color:'+smenuHoverBackground+'; cursor:hand}');
document.writeln ('</style>');
// Build and show the main menu items
function showMenus(quant,definedOrientation)
{
if(definedOrientation!=""){orientation=definedOrie ntation}
if (orientation.toLowerCase() == "vertical"){document.writeln ('<table border="0" cellpadding="0" cellspacing="'+styleBorder+'" bgColor="'+borderColor+'">')}
else{document.writeln ('<table border="0" cellpadding="0" cellspacing="'+styleBorder+'" bgColor="'+borderColor+'"><tr>')}
for (x=0; x<eval("Menu"+quant).length; x++)
{
if (orientation.toLowerCase()=="vertical") document.writeln('<tr>')
document.writeln ('<td onclick="tdMouseClick(\''+quant+'mainLink'+x+'\')" onMouseOver="hoverMenu(); popDown(\''+quant+'\','+x+', \''+quant+'button'+x+'\',\''+orientation+'\'); " onMouseOut="clearMenu('+quant+','+x+')" ')
if (menuStyle.toLowerCase() == "3d"){document.writeln ('style="border-left:'+cellBorder+'px solid '+borderHighlight+';border-top:'+cellBorder+'px solid '+borderHighlight+';border-right:'+cellBorder+'px solid '+borderShadow+';border-bottom:'+cellBorder+'px solid '+borderShadow+';"');}
document.writeln ('><div id="'+quant+'button'+x+'"><table border="0" cellpadding="'+cellPadding+'" cellspacing="0" width="100%"><tr><td class="rcMenuStatic" id="'+quant+'cell'+x+'" nowrap>');
document.writeln (''+eval("Menu"+quant)[x][0]+'</td>');
if (subIndicate == 1&&eval("subMenu"+quant)[x].length>=1){
document.writeln('<td class="rcMenuStatic" id="'+quant+'cell'+x+'a" align="right">');
document.writeln (''+indicator+'</td>');}
document.writeln ('</tr></table></div></td>');
if (orientation.toLowerCase()=="vertical") document.writeln('</tr>')
}
if (orientation.toLowerCase() == "vertical"){document.writeln ('</table>');}
else{document.writeln ('</tr></table>');}
// Build the sub menu items
for (x=0; x<eval("Menu"+quant).length; x++)
{
if (eval("subMenu"+quant)[x].length > 0)
{
document.writeln ('<div id="'+quant+'MENU'+x+'" style="visibility:hidden; position:absolute; z-index:2" >');
document.writeln ('<table border="0" cellpadding="'+cellPadding+'" cellspacing="'+styleBorder+'" bgColor="'+sborderColor+'">');
for (y=0; y<eval("subMenu"+quant)[x].length; y++)
{
document.writeln ('<tr><td id="'+quant+'subMenu'+x+y+'" class="rcSubMenuStatic" onMouseOver="hoverMenu(); highlightMenu(\'sub\','+x+','+y+',\'\','+quant+')" onMouseOut="clearMenu('+quant+','+x+');" onclick="tdMouseClick(\''+quant+'subLink'+x+y+'\') " nowrap')
if (menuStyle.toLowerCase() == "3d"){document.writeln ('style="border-left:'+cellBorder+'px solid '+sborderHighlight+';border-top:'+cellBorder+'px solid '+sborderHighlight+';border-right:'+cellBorder+'px solid '+sborderShadow+';border-bottom:'+cellBorder+'px solid '+sborderShadow+';"');}
document.writeln ('>'+eval("subMenu"+quant)[x][y][0]+'</td></tr>');
}
document.writeln ('</table></div>');
}
}
}
// Change colour or menu and submenu items when the mouse hovers over.
function highlightMenu(element,mainMenu,dropMenu,state,quan t)
{
hoverMenu();
state=(state == "hover")?"rcMenuHover":"rcMenuStatic"
if (element == "sub")
{
for (x=0; x < eval("subMenu"+quant)[mainMenu].length; x++)
{
eval(obj+'("'+quant+'subMenu'+mainMenu+x+'").class Name = "rcSubMenuStatic"')
eval(obj+'("'+quant+'subLink'+mainMenu+x+'").class Name = "rcSubMenuStatic"')
}
eval(obj+'("'+quant+'subMenu'+mainMenu+dropMenu+'" ).className="rcSubMenuHover"')
eval(obj+'("'+quant+'subLink'+mainMenu+dropMenu+'" ).className="rcSubMenuHover"')
}
else
{
eval(obj+'("'+quant+'cell'+mainMenu+'").className = "'+state+'"')
eval(obj+'("'+quant+'mainLink'+mainMenu+'").classN ame = "'+state+'"')
if (subIndicate == 1&&eval("subMenu"+quant)[mainMenu].length>=1)
{
eval(obj+'("'+quant+'cell'+mainMenu+'a").className = "'+state+'"')
eval(obj+'("'+quant+'mainLink'+mainMenu+'a").class Name = "'+state+'"')
}
}
}
// Find positioning for sub menus
function getOffset(obj, dim)
{
if(dim=="left")
{
oLeft = obj.offsetLeft;
while(obj.offsetParent!=null)
{
oParent = obj.offsetParent
oLeft += oParent.offsetLeft
obj = oParent
}
return oLeft
}
else if(dim=="top")
{
oTop = obj.offsetTop;
while(obj.offsetParent!=null)
{
oParent = obj.offsetParent
oTop += oParent.offsetTop
obj = oParent
}
return oTop
}
else if(dim=="width")
{
oWidth = obj.offsetWidth
return oWidth
}
else if(dim=="height")
{
oHeight = obj.offsetHeight
return oHeight
}
else
{
alert("Error: invalid offset dimension '" + dim + "' in getOffset()")
return false;
}
}
// Show sub menus
function popDown(quant, param, id, orientation)
{
var cellBorderOffset = (isNS6)?cellBorder:eval(cellBorder*2)
var browserAdjustment = (isNS6)?cellBorder:0
var menu;
var button;
if (id)
{
getOffset(eval(obj+'(id)'),'left');
getOffset(eval(obj+'(id)'),'top');
getOffset(eval(obj+'(id)'),'width');
getOffset(eval(obj+'(id)'),'height');
if (eval("Menu"+quant+"["+param+"][3]")=="right")
{
oLeft=oLeft
oLeft=oLeft+oWidth;
getOffset(eval(obj+'("'+quant+'MENU'+param+'")'),' width');
oLeft=oLeft-oWidth ;
alignAdjustment = cellBorder*2 + 1
}
else
{
alignAdjustment = 0
oLeft=oLeft
}
}
n = 0;
while (n < eval("Menu"+quant).length)
{
menu = quant+"MENU"+n
if (param == n)
{
theObj = eval(obj+'(menu)');
if (theObj)
{
theObj.style.visibility = "visible"
if (orientation.toLowerCase()=="vertical"){
theObj.style.left=(menuStyle.toLowerCase()=="flat" )?oLeft+oWidth+cellBorder+horizontalOffsetLeft+oWidth+cellBorderOffset+horizontalOffset;
theObj.style.top=(menuStyle.toLowerCase()=="flat") ?oTop-cellBorder+verticalOffsetTop+verticalOffset-browserAdjustment}
else{
theObj.style.left=(menuStyle.toLowerCase()=="flat" )?oLeft-cellBorder+horizontalOffset+alignAdjustmentLeft+horizontalOffset-browserAdjustment+alignAdjustment;
theObj.style.top=(menuStyle.toLowerCase()=="flat") ?oTop+oHeight+cellBorder+verticalOffsetTop+oHeight+cellBorderOffset+verticalOffset;}
}
highlightMenu('main',n,'','hover',quant)
if (eval("subMenu"+quant)[param].length > 0)
{
for (x=0; x<eval("subMenu"+quant)[param].length; x++)
{
eval (obj+'("'+quant+'subMenu'+param+x+'").className = "rcSubMenuStatic"')
eval (obj+'("'+quant+'subLink'+param+x+'").className = "rcSubMenuStatic"')
}
}
}
else
{
for (x=1; x<quantity+1; x++)
{
menu = x+"MENU"+n
//alert(menu)
if (eval(obj+'(menu)'))
{
eval(obj+'(menu).style.visibility = "hidden"')
}
highlightMenu ('main',n,'','static',quant)
}
}
n++
}
}
// Re-set timer for sub menus
function hoverMenu()
{
if(timer)
clearTimeout(timer)
}
// Set timer for sub menus
function clearMenu(quant,menu)
{
setDelay = subMenuDelay*1000
delay = (eval("subMenu"+quant)[menu].length > 0)?setDelay:1
timer = setTimeout("popDown("+quant+","+(eval("Menu"+quant ).length + 1)+")",delay)
}
// when you click the box, perform the same function as if the user had clicked the hyperlink
function tdMouseClick(theElement)
{
eval(obj+'(theElement).click()')
}
//-->
</script>
</head>
<body onresize="window.location.href = window.location.href">
e poi nella cella dove compare il menu:
<script>showMenus(1,'Horizontal')</script>