Forums Archive Index > SmartMenus 5 > Relative Positioning

Author: dunctait

Date: 26 May 2005 5:19 pm

Because absolute-positioning causes some problems (multi-browser problems mostly) i would prefer to have a relative position to the image in the navbar.
this is possible, and i coded my own version copying+pasting the sample working code that came with the package.

Code:
// SAMPLE FUNCTION USED FOR RELATIVE POSITIONING
function s_getStart(a){
var bodyMarginTop=0;// specify manually to get over bugs
var bodyMarginLeft=0;// in Opera 5/6, Konqueror<3.2 and IE5.x/Mac
var o=document.images["getStart"];if(!o)return a=="x"?-630:0;
if(s_nS4)return a=="x"?o.x:o.y;
var oP,oC,ieW;oP=o.offsetParent;oC=a=="x"?o.offsetLeft:o.offsetTop;
ieW=s_iE&&!s_mC?1:0;
while(oP){if(ieW&&oP.tagName&&oP.tagName.toLowerCase()=="table"&&oP.border&&oP.border>0)oC++;oC+=a=="x"?oP.offsetLeft:oP.offsetTop;oP=oP.offsetParent};
return s_oP7m||s_kN31p&&!s_kN32p||s_iE5M?a=="x"?s_oP7m?oC:oC+bodyMarginLeft:oC+bodyMarginTop:oC};
/*
All browsers have problems with finding the real position of an
element on the page in certain cases. I have tried to get over some
browser bugs with the above function- that's why it's so complex.
*/
// SAMPLE FUNCTION USED FOR RELATIVE POSITIONING


s_CSSred=['#EEEDF5 #554535 #554535 #EEEDF5','#554535',1,'#fffbf0',2,'#fffbf0','#bebddf','#ff0000','#000000','arial,helvetica,sans-serif','10pt','2','normal','center',5,1,'#bebddf','',true,'../images/arrow2.gif','../images/arrow3.gif',7,7,9,'#C0C0C0','#FFFFFF','../images/arrow2.gif',true,'../images/scrolltop.gif','../images/scrollbottom.gif',68,12,'','','',2,'#fffbf0','#8583BE #DDDCEA #DDDCEA #8583BE','#ff0000',1,'../images/separator_bg.gif'];


// === 4 === MENU DEFINITIONS
s_add(
{
N:'search',   // NAME
LV:1,      // LEVEL (look at IMPORTANT NOTES 1 in the Manual)
MinW:130,   // MINIMAL WIDTH
T:'s_getStart("y")+15',   // TOP (look at IMPORTANT HOWTOS 6 in the Manual)
L:'s_getstart("x")',   // LEFT (look at IMPORTANT HOWTOS 6 in the Manual)
P:false,   // menu is PERMANENT (you can only set true if this is LEVEL 1 menu)
S:s_CSSTop   // STYLE Array to use for this menu
},
[      // define items {U:'url',T:'text' ...} look at the Manual for details
{U:'http://www.google.com/',T:'Google'},
{U:'http://www.altavista.com/',T:'Altavista'},
{U:'http://www.search.com/',T:'CNET Search.com'},
{U:'http://www.lycos.com/',T:'Lycos'},
{U:'http://www.hotbot.com/',T:'Hotbot'}
]
);


the problem then, is that for Y this works fine, but if i then add in the s_getStart("x") then the submenu will not show at all.

this works fine in the sample and i cant figure out why it doesnt in mine.

any ideas?

thanks
dunctait


Author: smartmenus

Date: 27 May 2005 4:22 am

I can't guess what may be the reason for the issue without seeing an example page- the code looks fine. :?

Could you please provide me with some URL where I could investigate the issue? Or you could send me a small ZIP with one example page instead..

Thanks!