Forum Moderators: open

Message Too Old, No Replies

Problem with position on Firefox on this script

         

webstyler

7:03 am on Jun 9, 2006 (gmt 0)

10+ Year Member



Hi to all :)

I use ypSlideOutMenu for make menu on site...

the menu is position from center of page

all it's ok with ie
all it's ok in firefox ONLY if scrollbar is hidden.. else menu is 8px right respect ie and this make bad layout..

this is most interesting code of js

// Menu configuration Options
// var myOffset = 10;

// the number you pass to initLeft doesn't matter since it will get
// changed onactivate
// left, from top, width, height
var myMenu1 = new ypSlideOutMenu("menu1", "right", 0, 147, 150, 200); //
var myMenu2 = new ypSlideOutMenu("menu2", "right", 0, 171, 150, 200); //
var myMenu3 = new ypSlideOutMenu("menu3", "right", 0, 195, 150, 200); //

// for each menu, we set up the onactivate event to call repositionMenu with the amount offset from center, in pixels
myMenu1.onactivate = function() { repositionMenu(myMenu1, -213); }
myMenu2.onactivate = function() { repositionMenu(myMenu2, -213); }
myMenu3.onactivate = function() { repositionMenu(myMenu3, -213); }

------------------------------------

-213 is correct for ie
-213 is correct for firefox only if scrollbar is hidden.. (never on my layout)

? any help pls?

thks

webstyler

7:08 am on Jun 9, 2006 (gmt 0)

10+ Year Member



another piece of code..

---

// this function repositions a menu to the speicified offset from center
function repositionMenu(menu, offset)
{
// the new left position should be the center of the window + the offset
var newLeft = getWindowWidth() / 2 + offset;

// setting the left position in netscape is a little different than IE
menu.container.style? menu.container.style.left = newLeft + "px" : menu.container.left = newLeft;
}

// this function calculates the window's width - different for IE and netscape
function getWindowWidth()
{
return window.innerWidth? window.innerWidth : document.body.offsetWidth;
}

webstyler

7:46 am on Jun 9, 2006 (gmt 0)

10+ Year Member



can be solved with this

return window.innerWidth? (window.innerWidth-18) : document.body.offsetWidth;

"I have hadd -18 if FF"

but I don't think is best solution..