Przykładowe menu w javascript

Na pewnej stronie znalazłem kod javascript menu.

');

if (isVert) itemY += length + spacing;

else itemX += length + spacing;

}

if (isDOM) {

var newDiv = document.createElement('div');

document.getElementsByTagName('body').item(0).appendChild(newDiv);

newDiv.innerHTML = str;

ref = newDiv.style;

ref.position = 'absolute';

ref.visibility = 'hidden';

}


// Insert a div tag to the end of the BODY with menu HTML in place for IE4.

if (isIE4) {

document.body.insertAdjacentHTML('beforeEnd', '

’ + str + ’
‘); ref = getSty(‘menu’ + currMenu + ‘div’); } // In NS4, create a reference to a new layer and write the items to it. if (isNS4) { ref = new Layer(0); ref.document.write(str); ref.document.close(); } for (currItem = 1; currItem itemName = ‘menu’ + currMenu + ‘item’ + currItem; if (isDOM || isIE4) menu[currMenu][currItem].ref = getSty(itemName); if (isNS4) menu[currMenu][currItem].ref = ref.document[itemName]; } } with(menu[0][0]) { ref.left = x; ref.top = y; ref.visibility = ‘visible’; } } // Syntaxes: *** START EDITING HERE, READ THIS SECTION CAREFULLY! *** // // menu[menuNumber][0] = new Menu(Vertical menu? (true/false), ‘popout indicator’, left, top, // width, ‘mouseover colour’, ‘background colour’, ‘border stylesheet’, ‘text stylesheet’); // // Left and Top are measured on-the-fly relative to the top-left corner of its trigger, or // for the root menu, the top-left corner of the page. // // menu[menuNumber][itemNumber] = new Item(‘Text’, ‘URL’, ‘target frame’, length of menu item, // additional spacing to next menu item, number of target menu to popout); // // If no target menu (popout) is desired, set it to 0. Likewise, if your site does not use // frames, pass an empty string as a frame target. // // Something that needs explaining - the Vertical Menu setup. You can see most menus below // are ‘true’, that is they are vertical, except for the first root menu. The ‘length’ and // ‘width’ of an item depends on its orientation – length is how long the item runs for in // the direction of the menu, and width is the lateral dimension of the menu. Just look at // the examples and tweak the numbers, they’ll make sense eventually :). var menu = new Array(); // Default colours passed to most menu constructors (just passed to functions, not // a global variable - makes things easier to change later in bulk). var defOver = ‘#336699’, defBack = ‘#003366’; // Default ‘length’ of menu items - item height if menu is vertical, width if horizontal. var defLength = 22; // Menu 0 is the special, ‘root’ menu from which everything else arises. menu[0] = new Array(); // A non-vertical menu with a few different colours and no popout indicator, as an example. // *** MOVE ROOT MENU AROUND HERE *** it’s positioned at (5, 0) and is 17px high now. menu[0][0] = new Menu(false, ‘’, 5, 0, 17, ‘#669999’, ‘#006666’, ‘’, ‘itemText’); // Notice how the targets are all set to nonzero values… // The ‘length’ of each of these items is 40, and there is spacing of 10 to the next item. // Most of the links are set to ‘#’ hashes, make sure you change them to actual files. menu[0][1] = new Item(’ File’, ‘#’, ‘’, 40, 10, 1); menu[0][2] = new Item(’ Edit’, ‘#’, ‘’, 40, 10, 2); menu[0][3] = new Item(’ Help’, ‘#’, ‘’, 40, 10, 3); // An example of a link with a target frame/window as well… menu[0][4] = new Item(’ Site’, ‘http://gusnz.cjb.net’, ‘_new’, 40, 10, 0); // File menu. menu[1] = new Array(); // The File menu is positioned 0px across and 22 down from its trigger, and is 80 wide. // All text in this menu has the stylesheet class ‘item’ – see the

| |

[/code]

Podaj jakąś przykładową stronę z tym menu to ci powiem jak bo kodu rozkminiać mi się nie chce.

To wygląda na mega starą wersję tego: http://www.twinhelix.com/dhtml/popupmenu/

Ściągnij najnowszą wersję. W paczce też jest pełna dokumentacja co i jak.