Autor Zpráva
ala
Profil
Jak se dá udělat větvené menu(po nejetí se rozjede na skupinu odkazů).
Meleme
Profil
http://diskuse.jakpsatweb.cz/index.php?action=vthread&forum=1&topic=92 58
ala
Profil
V čem je chyba?


<html>


<HEAD>

<SCRIPT LANGUAGE="JavaScript">




var isDOM = false, isNS4 = false;
if (document.all) var isDOM = true, docObj = 'document.all.', styObj = '.style';
else if (document.layers) var isNS4 = true, docObj = 'document.', styObj = '';
// Hide timeout
var popTimer = 0;
var litNow = new Array();
function popOver(menuNum, itemNum) {
clearTimeout(popTimer);
hideAllBut(menuNum);
litNow = getTree(menuNum, itemNum);
changeCol(litNow, true);
targetNum = menu[menuNum][itemNum].target;
if (targetNum > 0) {
targetName = menu[targetNum][0].id;
menuName = menu[menuNum][0].id;
menuRef = eval(docObj + menuName + styObj);
thisX = parseInt(menuRef.left);
thisY = parseInt(menuRef.top);
// Add onto this the position of the trigger item within the menu
itemPath = docObj;
if (isNS4) itemPath += menuName + '.document.';
itemRef = eval(itemPath + menuName + itemNum.toString() + styObj);
thisX += parseInt(itemRef.left);
thisY += parseInt(itemRef.top);
// Add those to the target's offset to set the target's position, show it.
with (eval(docObj + targetName + styObj)) {
left = parseInt(thisX + menu[targetNum][0].x);
top = parseInt(thisY + menu[targetNum][0].y);
visibility = 'visible';
}
}
}
function popOut(menuNum, itemNum) {
// Hide menu in 1/2 sec, *UNLESS* another mouseover clears the timeout!
popTimer = setTimeout('hideAllBut(0)', 500);
}
function getTree(menuNum, itemNum) {
// Array index is the menu number. The contents are null (if that menu is not a parent)
// or the item number in that menu that is an ancestor (to light it up).
itemArray = new Array(menu.length);
while(1) {
itemArray[menuNum] = itemNum;
if (menuNum == 0) return itemArray;
itemNum = menu[menuNum][0].parentItem;
menuNum = menu[menuNum][0].parentMenu;
}
}
// Pass an array and a boolean to specify colour change, true = over colour.
function changeCol(changeArray, isOver) {
for (menuCount = 0; menuCount < changeArray.length; menuCount++) {
if (changeArray[menuCount]) {
thisMenu = menu[menuCount][0].id;
thisItem = thisMenu + changeArray[menuCount].toString();
newCol = isOver ? menu[menuCount][0].overCol : menu[menuCount][0].backCol;
if (isDOM) document.all[thisItem].style.backgroundColor = newCol;
if (isNS4) document[thisMenu].document[thisItem].bgColor = newCol;
}
}
}
function hideAllBut(menuNum) {
var keepMenus = getTree(menuNum, 1);
for (count = 0; count < menu.length; count++)
if (!keepMenus[count])
eval(docObj + menu[count][0].id + styObj + '.visibility = "hidden"');
changeCol(litNow, false);
}
// *** MENU CONSTRUCTION FUNCTIONS ***
// Variable to end a div or layer based on browser.
var endDL = isDOM ? '</div>' : '</layer>';
function Menu(id, x, y, width, overCol, backCol, borderCol) {
this.id = id;
this.x = x;
this.y = y;
this.width = width;
// Colours of menu and items.
this.overCol = overCol;
this.backCol = backCol;
this.borderCol = borderCol;
// Parent menu and item numbers, indexed later.
this.parentMenu = null;
this.parentItem = null;
}
function Item(text, href, height, target) {
this.text = text;
this.href = href;
this.height = height;
this.target = target;
}
function startDL(id, x, y, width, height, vis, back, border, zIndex, extraProps) {
// Write a div in IE that resembles a layer's settings, or a layer in NS.
if (isDOM) {
str = '<div id="' + id + '" style="position: absolute; left: ' + x + '; top: ' + y +
'; width: ' + width + '; height: ' + height + '; visibility: ' + vis + '; ';
if (back) str += 'background: ' + back + '; ';
if (border) str += 'padding: 3px; border: 1px solid ' + border + '; ';
if (zIndex) str += 'z-index: ' + zIndex + '; ';
// End style declaration.
str += '" ';
}
if (isNS4) {
str = '<layer id="' + id + '" left="' + x + '" top="' + y + '" width="' + width +
'" height="' + height + '" visibility="' + vis + '" ';
if (back) str += 'bgcolor="' + back + '" ';
if (border) str += 'style="border: 1px solid ' + border + '" ';
if (zIndex) str += 'z-index="' + zIndex + '" ';
}
return str + extraProps + '>';
}
function mouseProps(currMenu, currItem) {
return 'onMouseOver="popOver(' + currMenu + ',' + currItem + ')" onMouseOut="popOut(' + currMenu + ',' + currItem + ')"';
}
function writeMenus(customRoot, popInd) {
for (currMenu = 0; currMenu < menu.length; currMenu++) {
showMenu = true;
if ((currMenu == 0) && customRoot) {
document.write(customRoot);
showMenu = false;
}
with (menu[currMenu][0]) {
// Start generating a div with position offset - no dimensions, colours, mouseovers.
// This position is only relevant for root menu anyway as all others are altered later.
menuHTML = startDL(id, x, y, 0, 0, 'hidden', null, null, 100, '');
// Width is less padding (3 left & right) and border (1 left & right).
var back = backCol, bord = borderCol, currWidth = width - 8;
}
// Y-position of next item, increase if you want a menu header.
itemPos = 0;
// Remember, items start from 1 in the array (0 is menu object itself, above).
for (currItem = 1; currItem < menu[currMenu].length; currItem++) {
// Auto-generate ID's in numerical sequence.
trigID = menu[currMenu][0].id + currItem.toString();
// Now, work with properties of individual menu items.
with (menu[currMenu][currItem]) {
// Start a menu item positioned vertically, with mouse events and colours.
menuHTML += startDL(trigID, 0, itemPos, 0, 0, 'inherit', back, bord, 100, mouseProps(currMenu, currItem)) + '<table width="' + currWidth + '" border="0" cellspacing="0" cellpadding="0"><tr>' + '<td align="left"><a class="Item" href="' + href + '">' + text + '</a></td>' + '<td class="Item" align="right">' + (target ? popInd : '') + '</td></tr></table>' + endDL;
if (target > 0) {
// Set target's parents to this and offset it by the current position.
menu[target][0].parentMenu = currMenu;
menu[target][0].parentItem = currItem;
}
// Move next item position down by this item's height.
itemPos += height;
}
}
// Write this menu to the document.
if (showMenu) document.write(menuHTML + endDL);
litNow[currMenu] = null;
}
}
// End -->
</script>
<style>
<!--
.Item { text-decoration: none; color: #000000; font: 12px Arial, Helvetica }
-->
</style>
</HEAD>


<BODY>
<center>
<SCRIPT LANGUAGE="JavaScript">


/* Syntaxes:
*
* menu[menuNumber][0] = new Menu('menu ID', left, top, width, 'mouseover colour',
*'background colour', 'border colour');
* Left and Top are measured on-the-fly relative to the top-left corner of its trigger.
*
* menu[menuNumber][itemNumber] = new Item('Text', 'URL', vertical spacing to next item,
*target menu number);
* If no target menu (popout) is desired, set it to 0. All menus must trace back their
* targets to the root menu! That is, every menu must be targeted by one item somewhere.
* Even if you're not writing the root menu, you must still specify its settings here.
*/
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).
var defOver = '#5CA7EB', defBack = '#E8F3FD', defBorder = '#000000';
// Default height of menu items - the spacing to the next item, actually.
var defHeight = 22;
// Menu 0 is the special, 'root' menu from which everything else arises.
menu[0] = new Array();
// Pass a few different colours, as an example.
menu[0][0] = new Menu('rootMenu', 0, 0, 80, '#E8F3FD', '#E8F3FD', defBorder);
// Notice how the targets are all set to nonzero values...
menu[0][1] = new Item('Menu', '#', defHeight, 1);
menu[0][2] = new Item('Disciplíny', '#', defHeight, 2);
menu[0][3] = new Item('Ostatní', '#', defHeight, 3);
menu[1] = new Array();
// The File menu is positioned 0px across and 22 down from its trigger, and is 80 wide.
menu[1][0] = new Menu('menuMenu', 0, 22, 80, defOver, defBack, defBorder);
menu[1][1] = new Item('Home', '#', defHeight, 0);
menu[1][2] = new Item('Historie koní', '#', defHeight, 0);
menu[1][3] = new Item('Pohlaví', '#', defHeight, 0);
menu[1][4] = new Item('Plemena', '#', defHeight, 0);
menu[1][5] = new Item('Chov a péče', '#', defHeight, 0);
menu[1][6] = new Item('Výživa', '#', defHeight, 0);
menu[1][7] = new Item('Zdraví', '#', defHeight, 0);
menu[1][8] = new Item('Vybavení', '#', defHeight, 0);
menu[1][9] = new Item('Výcvik', '#', defHeight, 0);
menu[1][10] = new Item('Jízdárenské cviky', '#', defHeight, 0);
menu[1][11] = new Item('Příběhy', '#', defHeight, 0);
menu[1][12] = new Item('Galerie', '#', defHeight, 0);
menu[1][13] = new Item('Diskuze', '#', defHeight, 0);
menu[2] = new Array();
menu[2][0] = new Menu('disciplínyMenu', 0, 22, 80, defOver, defBack,
ala
Profil
<html>


<HEAD>

<SCRIPT LANGUAGE="JavaScript">




var isDOM = false, isNS4 = false;
if (document.all) var isDOM = true, docObj = 'document.all.', styObj = '.style';
else if (document.layers) var isNS4 = true, docObj = 'document.', styObj = '';
// Hide timeout
var popTimer = 0;
var litNow = new Array();
function popOver(menuNum, itemNum) {
clearTimeout(popTimer);
hideAllBut(menuNum);
litNow = getTree(menuNum, itemNum);
changeCol(litNow, true);
targetNum = menu[menuNum][itemNum].target;
if (targetNum > 0) {
targetName = menu[targetNum][0].id;
menuName = menu[menuNum][0].id;
menuRef = eval(docObj + menuName + styObj);
thisX = parseInt(menuRef.left);
thisY = parseInt(menuRef.top);
// Add onto this the position of the trigger item within the menu
itemPath = docObj;
if (isNS4) itemPath += menuName + '.document.';
itemRef = eval(itemPath + menuName + itemNum.toString() + styObj);
thisX += parseInt(itemRef.left);
thisY += parseInt(itemRef.top);
// Add those to the target's offset to set the target's position, show it.
with (eval(docObj + targetName + styObj)) {
left = parseInt(thisX + menu[targetNum][0].x);
top = parseInt(thisY + menu[targetNum][0].y);
visibility = 'visible';
}
}
}
function popOut(menuNum, itemNum) {
// Hide menu in 1/2 sec, *UNLESS* another mouseover clears the timeout!
popTimer = setTimeout('hideAllBut(0)', 500);
}
function getTree(menuNum, itemNum) {
// Array index is the menu number. The contents are null (if that menu is not a parent)
// or the item number in that menu that is an ancestor (to light it up).
itemArray = new Array(menu.length);
while(1) {
itemArray[menuNum] = itemNum;
if (menuNum == 0) return itemArray;
itemNum = menu[menuNum][0].parentItem;
menuNum = menu[menuNum][0].parentMenu;
}
}
// Pass an array and a boolean to specify colour change, true = over colour.
function changeCol(changeArray, isOver) {
for (menuCount = 0; menuCount < changeArray.length; menuCount++) {
if (changeArray[menuCount]) {
thisMenu = menu[menuCount][0].id;
thisItem = thisMenu + changeArray[menuCount].toString();
newCol = isOver ? menu[menuCount][0].overCol : menu[menuCount][0].backCol;
if (isDOM) document.all[thisItem].style.backgroundColor = newCol;
if (isNS4) document[thisMenu].document[thisItem].bgColor = newCol;
}
}
}
function hideAllBut(menuNum) {
var keepMenus = getTree(menuNum, 1);
for (count = 0; count < menu.length; count++)
if (!keepMenus[count])
eval(docObj + menu[count][0].id + styObj + '.visibility = "hidden"');
changeCol(litNow, false);
}
// *** MENU CONSTRUCTION FUNCTIONS ***
// Variable to end a div or layer based on browser.
var endDL = isDOM ? '</div>' : '</layer>';
function Menu(id, x, y, width, overCol, backCol, borderCol) {
this.id = id;
this.x = x;
this.y = y;
this.width = width;
// Colours of menu and items.
this.overCol = overCol;
this.backCol = backCol;
this.borderCol = borderCol;
// Parent menu and item numbers, indexed later.
this.parentMenu = null;
this.parentItem = null;
}
function Item(text, href, height, target) {
this.text = text;
this.href = href;
this.height = height;
this.target = target;
}
function startDL(id, x, y, width, height, vis, back, border, zIndex, extraProps) {
// Write a div in IE that resembles a layer's settings, or a layer in NS.
if (isDOM) {
str = '<div id="' + id + '" style="position: absolute; left: ' + x + '; top: ' + y +
'; width: ' + width + '; height: ' + height + '; visibility: ' + vis + '; ';
if (back) str += 'background: ' + back + '; ';
if (border) str += 'padding: 3px; border: 1px solid ' + border + '; ';
if (zIndex) str += 'z-index: ' + zIndex + '; ';
// End style declaration.
str += '" ';
}
if (isNS4) {
str = '<layer id="' + id + '" left="' + x + '" top="' + y + '" width="' + width +
'" height="' + height + '" visibility="' + vis + '" ';
if (back) str += 'bgcolor="' + back + '" ';
if (border) str += 'style="border: 1px solid ' + border + '" ';
if (zIndex) str += 'z-index="' + zIndex + '" ';
}
return str + extraProps + '>';
}
function mouseProps(currMenu, currItem) {
return 'onMouseOver="popOver(' + currMenu + ',' + currItem + ')" onMouseOut="popOut(' + currMenu + ',' + currItem + ')"';
}
function writeMenus(customRoot, popInd) {
for (currMenu = 0; currMenu < menu.length; currMenu++) {
showMenu = true;
if ((currMenu == 0) && customRoot) {
document.write(customRoot);
showMenu = false;
}
with (menu[currMenu][0]) {
// Start generating a div with position offset - no dimensions, colours, mouseovers.
// This position is only relevant for root menu anyway as all others are altered later.
menuHTML = startDL(id, x, y, 0, 0, 'hidden', null, null, 100, '');
// Width is less padding (3 left & right) and border (1 left & right).
var back = backCol, bord = borderCol, currWidth = width - 8;
}
// Y-position of next item, increase if you want a menu header.
itemPos = 0;
// Remember, items start from 1 in the array (0 is menu object itself, above).
for (currItem = 1; currItem < menu[currMenu].length; currItem++) {
// Auto-generate ID's in numerical sequence.
trigID = menu[currMenu][0].id + currItem.toString();
// Now, work with properties of individual menu items.
with (menu[currMenu][currItem]) {
// Start a menu item positioned vertically, with mouse events and colours.
menuHTML += startDL(trigID, 0, itemPos, 0, 0, 'inherit', back, bord, 100, mouseProps(currMenu, currItem)) + '<table width="' + currWidth + '" border="0" cellspacing="0" cellpadding="0"><tr>' + '<td align="left"><a class="Item" href="' + href + '">' + text + '</a></td>' + '<td class="Item" align="right">' + (target ? popInd : '') + '</td></tr></table>' + endDL;
if (target > 0) {
// Set target's parents to this and offset it by the current position.
menu[target][0].parentMenu = currMenu;
menu[target][0].parentItem = currItem;
}
// Move next item position down by this item's height.
itemPos += height;
}
}
// Write this menu to the document.
if (showMenu) document.write(menuHTML + endDL);
litNow[currMenu] = null;
}
}
// End -->
</script>
<style>
<!--
.Item { text-decoration: none; color: #000000; font: 12px Arial, Helvetica }
-->
</style>
</HEAD>


<BODY>
<center>
<SCRIPT LANGUAGE="JavaScript">


/* Syntaxes:
*
* menu[menuNumber][0] = new Menu('menu ID', left, top, width, 'mouseover colour',
*'background colour', 'border colour');
* Left and Top are measured on-the-fly relative to the top-left corner of its trigger.
*
* menu[menuNumber][itemNumber] = new Item('Text', 'URL', vertical spacing to next item,
*target menu number);
* If no target menu (popout) is desired, set it to 0. All menus must trace back their
* targets to the root menu! That is, every menu must be targeted by one item somewhere.
* Even if you're not writing the root menu, you must still specify its settings here.
*/
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).
var defOver = '#5CA7EB', defBack = '#E8F3FD', defBorder = '#000000';
// Default height of menu items - the spacing to the next item, actually.
var defHeight = 22;
// Menu 0 is the special, 'root' menu from which everything else arises.
menu[0] = new Array();
// Pass a few different colours, as an example.
menu[0][0] = new Menu('rootMenu', 0, 0, 80, '#E8F3FD', '#E8F3FD', defBorder);
// Notice how the targets are all set to nonzero values...
menu[0][1] = new Item('Menu', '#', defHeight, 1);
menu[0][2] = new Item('Disciplíny', '#', defHeight, 2);
menu[0][3] = new Item('Ostatní', '#', defHeight, 3);
menu[1] = new Array();
// The File menu is positioned 0px across and 22 down from its trigger, and is 80 wide.
menu[1][0] = new Menu('menuMenu', 0, 22, 80, defOver, defBack, defBorder);
menu[1][1] = new Item('Home', '#', defHeight, 0);
menu[1][2] = new Item('Historie koní', '#', defHeight, 0);
menu[1][3] = new Item('Pohlaví', '#', defHeight, 0);
menu[1][4] = new Item('Plemena', '#', defHeight, 0);
menu[1][5] = new Item('Chov a péče', '#', defHeight, 0);
menu[1][6] = new Item('Výživa', '#', defHeight, 0);
menu[1][7] = new Item('Zdraví', '#', defHeight, 0);
menu[1][8] = new Item('Vybavení', '#', defHeight, 0);
menu[1][9] = new Item('Výcvik', '#', defHeight, 0);
menu[1][10] = new Item('Jízdárenské cviky', '#', defHeight, 0);
menu[1][11] = new Item('Příběhy', '#', defHeight, 0);
menu[1][12] = new Item('Galerie', '#', defHeight, 0);
menu[1][13] = new Item('Diskuze', '#', defHeight, 0);
menu[2] = new Array();
menu[2][0] = new Menu('disciplínyMenu', 0, 22, 80, defOver, defBack, defBorder);
menu[2][
ala
Profil
Mám to tady. Jak to mám vycentrovat a přejmenovat ty hlavní body menu?
peta
Profil *
ala www.rar.cz/rarnova/ - okopiruj si script, bez js se ti to menu zobrazi totiz taky, na tve strance se mi ve Firefox nezobrazi absolutne nic. A IE nepoustim, IE neni virove bezpecny.

Jo, a nespamuj vice nez 1 forum, nejlepe javascriptove, kdyz pouzivas javascript.
ala
Profil
Jaký scripty si mám skopírovat?
peta
Profil *
ala
Firefox - menu nahore Zobrazit - Zdrojovy hod
Soucasti stranky vidim podle head, ze je style.css...
V style.css vidim, ze je odkaz na jakysi csshover.htc
a v csshover.htc vidim, ze je to JS
takze asi ten?
Potom tam dale vidiz ve strance odkaz na script jiny, tak ten si zkopiruj taky (aspon myslim, ze jsem tam nahraval novejsi verzi)

Ve firefox se ti to menu bude zobrazovat oki i bez csshover.htc .

mno a pokud se ti nelibi, ze jsou tam 2 scripty, muzes tam udelat jen hotove menu, jako je na www.volny.cz/dvereapodlahy/
Tam je totez, jen se menu nevpisuje dalsim scriptem.
ala
Profil
Jenže mě to nejde zobrazit a tak si to stáhnu dost těžko...
Toto téma je uzamčeno. Odpověď nelze zaslat.

0