Autor Zpráva
kovarik
Profil
Chci dát na web rozbalovací menu a hodiny,ale vždy když mám hodiny nebo nějaký jiný script tak se mi neschovává menu .Co stím mám udělat předem dekuji za odpověd.
Peca
Profil
Spravit to... Nebude tam problém s časováním?
kovarik
Profil
Peca

Já nevím já se scripty začínám
Oswald
Profil
Bez prohlédnutí těch se skriptů se příčina hledá těžko. Tipl bych si, že oba využívají window.onload a ten později vložený ho přepíše tomu prvnímu. Pokud je to tak, tak řešení je vytvořit si vlastní funkci, a vložit tam volání obou a tu teprve přiřadit do window.onload. Pokud to teď vypadá nějak takto:



// menu.js
window.onload = menu;

// hodiny.js
window.onload = hodiny;


tak ty řádky odstranit a přidat tam toto:

window.onload = function() {

menu();
hodiny();
}
kovarik
Profil
<!-- Original Author unknown -->
<SCRIPT language=JavaScript>
dCol='000000';//date colour.
fCol='000000';//face colour.
sCol='000000';//seconds colour.
mCol='000000';//minutes colour.
hCol='000000';//hours colour.
ClockHeight=40;
ClockWidth=40;
ClockFromMouseY=0;
ClockFromMouseX=100;

//Alter nothing below! Alignments will be lost!

d=new Array("SUNDAY","MONDAY","TUESDAY","WEDNESDAY","THURSDAY","FRIDAY","SAT URDAY");
m=new Array("JANUARY","FEBRUARY","MARCH","APRIL","MAY","JUNE","JULY","AUGUST ","SEPTEMBER","OCTOBER","NOVEMBER","DECEMBER");
date=new Date();
day=date.getDate();
year=date.getYear();
if (year < 2000) year=year+1900;
TodaysDate=" "+d[date.getDay()]+" "+day+" "+m[date.getMonth()]+" "+year;
D=TodaysDate.split('');
H='...';
H=H.split('');
M='....';
M=M.split('');
S='.....';
S=S.split('');
Face='1 2 3 4 5 6 7 8 9 10 11 12';
font='Arial';
size=1;
speed=0.6;
ns=(document.layers);
ie=(document.all);
Face=Face.split(' ');
n=Face.length;
a=size*10;
ymouse=0;
xmouse=0;
scrll=0;
props="<font face="+font+" size="+size+" color="+fCol+"><B>";
props2="<font face="+font+" size="+size+" color="+dCol+"><B>";
Split=360/n;
Dsplit=360/D.length;
HandHeight=ClockHeight/4.5
HandWidth=ClockWidth/4.5
HandY=-7;
HandX=-2.5;
scrll=0;
step=0.06;
currStep=0;
y=new Array();x=new Array();Y=new Array();X=new Array();
for (i=0; i < n; i++){y[i]=0;x[i]=0;Y[i]=0;X[i]=0}
Dy=new Array();Dx=new Array();DY=new Array();DX=new Array();
for (i=0; i < D.length; i++){Dy[i]=0;Dx[i]=0;DY[i]=0;DX[i]=0}
if (ns){
for (i=0; i < D.length; i++)
document.write('<layer name="nsDate'+i+'" top=0 left=0 height='+a+' width='+a+'><center>'+props2+D[i]+'</font></center></layer>');
for (i=0; i < n; i++)
document.write('<layer name="nsFace'+i+'" top=0 left=0 height='+a+' width='+a+'><center>'+props+Face[i]+'</font></center></layer>');
for (i=0; i < S.length; i++)
document.write('<layer name=nsSeconds'+i+' top=0 left=0 width=15 height=15><font face=Arial size=3 color='+sCol+'><center><b>'+S[i]+'</b></center></font></layer>');
for (i=0; i < M.length; i++)
document.write('<layer name=nsMinutes'+i+' top=0 left=0 width=15 height=15><font face=Arial size=3 color='+mCol+'><center><b>'+M[i]+'</b></center></font></layer>');
for (i=0; i < H.length; i++)
document.write('<layer name=nsHours'+i+' top=0 left=0 width=15 height=15><font face=Arial size=3 color='+hCol+'><center><b>'+H[i]+'</b></center></font></layer>');
}
if (ie){
document.write('<div id="Od" style="position:absolute;top:0px;left:0px"><div style="position:relative">');
for (i=0; i < D.length; i++)
document.write('<div id="ieDate" style="position:absolute;top:0px;left:0;height:'+a+';width:'+a+';text- align:center">'+props2+D[i]+'</B></font></div>');
document.write('</div></div>');
document.write('<div id="Of" style="position:absolute;top:0px;left:0px"><div style="position:relative">');
for (i=0; i < n; i++)
document.write('<div id="ieFace" style="position:absolute;top:0px;left:0;height:'+a+';width:'+a+';text- align:center">'+props+Face[i]+'</B></font></div>');
document.write('</div></div>');
document.write('<div id="Oh" style="position:absolute;top:0px;left:0px"><div style="position:relative">');
for (i=0; i < H.length; i++)
document.write('<div id="ieHours" style="position:absolute;width:16px;height:16px;font-family:Arial;font -size:16px;color:'+hCol+';text-align:center;font-weight:bold">'+H[i]+' </div>');
document.write('</div></div>');
document.write('<div id="Om" style="position:absolute;top:0px;left:0px"><div style="position:relative">');
for (i=0; i < M.length; i++)
document.write('<div id="ieMinutes" style="position:absolute;width:16px;height:16px;font-family:Arial;font -size:16px;color:'+mCol+';text-align:center;font-weight:bold">'+M[i]+' </div>');
document.write('</div></div>')
document.write('<div id="Os" style="position:absolute;top:0px;left:0px"><div style="position:relative">');
for (i=0; i < S.length; i++)
document.write('<div id="ieSeconds" style="position:absolute;width:16px;height:16px;font-family:Arial;font -size:16px;color:'+sCol+';text-align:center;font-weight:bold">'+S[i]+' </div>');
document.write('</div></div>')
}
(ns)?window.captureEvents(Event.MOUSEMOVE):0;
function Mouse(evnt){
ymouse = (ns)?evnt.pageY+ClockFromMouseY-(window.pageYOffset):event.y+ClockFrom MouseY;
xmouse = (ns)?evnt.pageX+ClockFromMouseX:event.x+ClockFromMouseX;
}
(ns)?window.onMouseMove=Mouse:document.onmousemove=Mouse;
function ClockAndAssign(){
time = new Date ();
secs = time.getSeconds();
sec = -1.57 + Math.PI * secs/30;
mins = time.getMinutes();
min = -1.57 + Math.PI * mins/30;
hr = time.getHours();
hrs = -1.575 + Math.PI * hr/6+Math.PI*parseInt(time.getMinutes())/360;
if (ie){
Od.style.top=window.document.body.scrollTop;
Of.style.top=window.document.body.scrollTop;
Oh.style.top=window.document.body.scrollTop;
Om.style.top=window.document.body.scrollTop;
Os.style.top=window.document.body.scrollTop;
}
for (i=0; i < n; i++){
var F=(ns)?document.layers['nsFace'+i]:ieFace[i].style;
F.top=y[i] + ClockHeight*Math.sin(-1.0471 + i*Split*Math.PI/180)+scrll;
F.left=x[i] + ClockWidth*Math.cos(-1.0471 + i*Split*Math.PI/180);
}
for (i=0; i < H.length; i++){
var HL=(ns)?document.layers['nsHours'+i]:ieHours[i].style;
HL.top=y[i]+HandY+(i*HandHeight)*Math.sin(hrs)+scrll;
HL.left=x[i]+HandX+(i*HandWidth)*Math.cos(hrs);
}
for (i=0; i < M.length; i++){
var ML=(ns)?document.layers['nsMinutes'+i]:ieMinutes[i].style;
ML.top=y[i]+HandY+(i*HandHeight)*Math.sin(min)+scrll;
ML.left=x[i]+HandX+(i*HandWidth)*Math.cos(min);
}
for (i=0; i < S.length; i++){
var SL=(ns)?document.layers['nsSeconds'+i]:ieSeconds[i].style;
SL.top=y[i]+HandY+(i*HandHeight)*Math.sin(sec)+scrll;
SL.left=x[i]+HandX+(i*HandWidth)*Math.cos(sec);
}
for (i=0; i < D.length; i++){
var DL=(ns)?document.layers['nsDate'+i]:ieDate[i].style;
DL.top=Dy[i] + ClockHeight*1.5*Math.sin(currStep+i*Dsplit*Math.PI/180)+scrll;
DL.left=Dx[i] + ClockWidth*1.5*Math.cos(currStep+i*Dsplit*Math.PI/180);
}
currStep-=step;
}
function Delay(){
scrll=(ns)?window.pageYOffset:0;
Dy[0]=Math.round(DY[0]+=((ymouse)-DY[0])*speed);
Dx[0]=Math.round(DX[0]+=((xmouse)-DX[0])*speed);
for (i=1; i < D.length; i++){
Dy[i]=Math.round(DY[i]+=(Dy[i-1]-DY[i])*speed);
Dx[i]=Math.round(DX[i]+=(Dx[i-1]-DX[i])*speed);
}
y[0]=Math.round(Y[0]+=((ymouse)-Y[0])*speed);
x[0]=Math.round(X[0]+=((xmouse)-X[0])*speed);
for (i=1; i < n; i++){
y[i]=Math.round(Y[i]+=(y[i-1]-Y[i])*speed);
x[i]=Math.round(X[i]+=(x[i-1]-X[i])*speed);
}
ClockAndAssign();
setTimeout('Delay()',20);
}
if (ns||ie)window.onload=Delay;
</SCRIPT>

a na roletku to vypadá takto:

<!--SCRIPT BY SCHUBERT - [schubert_94_2000@yahoo.com]-->
<!--YOU ARE NOT AUTHORIZED TO SELL THIS SCRIPT-->
<!--DONT REMOVE THESE COMMENTS-->
<html><head>
<style type="text/css">
body{font-family:tahoma;font-size:10pt}
A:hover{color:blue;font-weight:bold;text-decoration:underline}
a{text-decoration:none}
</style>
<!--change the title to your web page name-->
<title>DropDown Menu</title>
<script language="JavaScript">
<!-- INSTRUCTIONS
/*
READ THESE INSTRUCTIONS AND CHANGE THE VARIABLES ACCORDINGLY
*/
var menu_pos=0;
/* menu_pos - the value 0 means the menu will be hidden when the page is opened and if value is set to 1 then the menu will be shown when the page is opened */
var menu_speed=10;
/* menu_speed - this value allows you to change the speed of the menu. (1 to 10) (1 is the slowest) Note that the lower the speed the smoother the menu is */
var instant_close=0;
/* instant_close - if you want the menu to close as soon as the user leaves the menu, set this value to 1 else 0 */

//Don't change anything after this line unless you know what youre doing
//Cheers from Schubert

if (menu_speed > 10)
{
menu_speed=10;
}
if(document.all)
{
doc = "document.all";
sty = ".style";
htm = ""
}
else if(document.layers)
{
doc = "document";
sty = "";
htm = ".document"
}

function positionLayers()
{
abcObj = eval(doc + '["abcLyr"]' + sty);
abcObj.left = 5;
if(menu_pos==0)
{
abcObj.top = -265;
kovarik
Profil
else
{
abcObj.top = 2;
}
}
function pullitup()
{
if (window.dropdown)
{
clearInterval(dropdown)
}
pullup=setInterval("uplift()",1)
}
function dropitdown()
{
if (window.pullup)
{
clearInterval(pullup)
}
dropdown=setInterval("downlift()",1)
}
function uplift()
{
var x_pos1 = parseInt(abcObj.top);
if(x_pos1 >= -260 )
{
if(instant_close==1)
{
abcObj.top=-265;
}
else if(instant_close==0)
{
abcObj.top = x_pos1-menu_speed;
}
}
else if (window.pullup)
{
clearInterval(pullup);
}
}
function downlift()
{
var x_pos1 = parseInt(abcObj.top);
if(x_pos1 < 0 )
{
abcObj.top = x_pos1+menu_speed;
}
else if (window.dropdown)
{
clearInterval(dropdown);
}
}
function info()
{
alert("This script is copyrighted to Schubert - schubert_94_2000@yahoo.com.");
}
// end it-->
</script>
</head>
<body onload="positionLayers();" bgcolor="bisque" vlink="red" alink="red" link="red" leftmargin="15" rightmargin="15" topmargin="25">
<div id="abcLyr" style="position:absolute;left:5px;top:4px;width:100px;height:300px;z-i ndex:100;visibility:visible;" onmouseover="dropitdown()" onmouseout="pullitup()">
<table bgcolor="#ffffff" width="200" height="300" border="6" bordercolor="#000000" bordercolordark="#000000" bordercolorlight="#808080" cellspacing="0">
<tr><td align="left" valign="middle"> <b>Contents &raquo;</b></td></tr>
<tr><td align="center" valign="middle" nowrap><a href="#">Menu item 1
</a></td></tr>
<tr><td align="center" valign="middle" nowrap><a href="#">Menu item 2</a></td></tr>
<tr><td align="center" valign="middle" nowrap><a href="#">Menu item 3</a></td></tr>
<tr><td align="center" valign="middle" nowrap><a href="#">Menu item 3</a></td></tr>
<tr><td align="center" valign="middle" nowrap><a href="#">Menu item 5</a></td></tr>
<tr><td align="center" valign="middle" nowrap><a href="javascript:info()">Information</a></td></tr>
<tr><td align="center" valign="middle" nowrap><font size="-1"><b><u>MY MENU</u></b></font></td></tr>
<!--<tr><td align="center" valign="bottom"><font size="-2"><b>Menu &raquo;</b> <a href="javascript:void(0)" onclick="downlift()"><b>Show</b></a> <b>/</b> <a href="javascript:void(0)" onclick="uplift()"><b>Hide</b></a></font></td></tr>-->
</table>
</div>


<!-- START CHANGING HERE -->


<h2 align="center">Drop Down Menu 2.0</h2>
<hr color="#000000" noshade>
Version 2.0 featuring....<br>
<b>Hover effect.</b><br>
<b>Menu item underlining on mouse over.</b><br><br>
Read the source code and change the variables accordingly.
Customizable values are -
<br><br>
<ul>
<li>Iinitially hidden or initially visible
<li>Menu Speed (1-10)
<li>Instant close (0 or 1)
</ul>
<big><b><u>Customizable</u></b></big>
<p>
1. Now, you can customize the menu by changing the source code. The instructions are given to change which variable to what number and what will happen.
<br><br>
2. Change the menu speed also. Menu speed can be anything from 1 - 10
</p>
<hr color="#000000" noshade>
Make copies of this page for all the pages of your site, so that the menu can be accessed from any page. Cheers!
<!-- STOP CHANGING HERE -->
</body>
</html>
<!-- Simba says Roar. -->

Budu velmi rád za každou radu děkuji
Timy
Profil
Já ti poradím jinak, hodiny ze stránky vyhoď, stejně je to nesmysl.
peta
Profil *
kovarik
1. zakladem dobre otazky je odkaz na stranku. Co jsi myslis poresil tim, ze jsi sem dal pres 2 zpravy velky zdrojovy kod? Vysledkem je, ze si to pracne musime zkopcit do editoru a odzkouset misto spusteni...

2. Viz Timy, JS hodiny jsou obvykle synchronizovany podle JS na pocitaci, kde se script spousti. Cili, kdyz si nastavim patek 13ho 12:00 tak bude patek 13 12:00 a nic ijne.
Kdyz to zasychronizujes podle serveru, treba pres PHP, pak zase mas cas serveru, ktery nemusi byt presny.
Cili, jaky to ma ucel mit tam cas? Jestli je to ucelne, tak to tam dej.

3. Ten zdrojovy kod je naprosty unikat :) Jednak pouzivas IE prvky, ktere v jinem prohizeci nepojedou. Coz by ani tak neva, kdyby to bylo validni.
Druhak tam mas dost slozite postavene menu (cili kod, ktery by sel zjednodusit za stejneho vysledku)
<tr><td align="center" valign="middle" nowrap><a href="#">Menu item 2</a></td></tr>
<tr><td align="center" valign="middle" nowrap><a href="#">Menu item 3</a></td></tr>
<tr><td align="center" valign="middle" nowrap><a href="#">Menu item 3</a></td></tr>
<tr><td align="center" valign="middle" nowrap><a href="#">Menu item 5</a></td></tr>

<style>
ul.menu li {display:block;textalign:center}
</style>
<ul class="menu">
<li><a href="#">Menu item 2</a></li>
<li><a href="#">Menu item 3</a></li>
<li><a href="#">Menu item 4</a></li>
<li><a href="#">Menu item 5</a></li>
</ul>

atd...

Timy Treba takove chaty zobrazuji narozeniny, ale take mi neni jasne, co se docili zobrazenim casu, kdyz je dole na liste? Zbytecna duplicita.
Toto téma je uzamčeno. Odpověď nelze zaslat.