Crossroads of Shinigami

Информация о пользователе

Привет, Гость! Войдите или зарегистрируйтесь.


Вы здесь » Crossroads of Shinigami » Общее » Скрипты


Скрипты

Сообщений 121 страница 150 из 151

121

Кнопка с цветным текстом

Код:
<script>
function h(color)
{
hn = new Array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A" ,"B", "C", "D", "E", "F")
if(color<0){return "00"}
else if(color>255){
return "FF"
}
else {
 s = "" + hn[Math.floor(color/16)] + hn[color%16]
 return s
 }
}
function toH(red, green, blue){
return h(red) + h(green) + h(blue)
}
function RGB(red, green, blue){
return toH(red, green, blue)
}
</script>
<script>
var sR = 5
var sG = 256
var sB = 56
var R = 5
var G = 256
var B = 256
var b = true;
function setButtonColor(r, g, b) {
document.all["button"].style.color=RGB(r, g, b);
}
function startChanging(){
if(b==true) {
 if((R>256)||(G>256)||(B>256))  {
  b=false;
  }
 R+=sR;G+=sG;B+=sB;
 }
else {
 if((R<0)||(G<0)||(B<0))  {
  b=true;
  }
 R-=sR; G-=sG; B-=sB 
 }
setButtonColor(R, G, B);
setTimeout("startChanging()", 3)
}
</script>
</head>
<body  onload="startChanging()">
<button style="background-color:#ffff33; font: 8pt Fixedsys;" id="button"><p>Кнопка с цветным текстом</p></button>

0

122

Музыкальная шкатулка, при каждой загрузке новая музыка

Код:
<SCRIPT>
//<!-- 
var midi = ""
var txt = ""
var nummidis = 5
day = new Date() 
seed = day.getTime()
ran = parseInt(((seed - (parseInt(seed/1000,10) * 1000))/10)/100*nummidis
+ 1,10)
if (ran == (1))
{midi=("herbst.mid");
txt=("herbst.mid")}
if (ran == (2))
{midi=("baby.mid");
txt=("baby.mid")}
if (ran == (3))
{midi=("gemeinde.mid");
txt=("gemeinde.mid")}
if (ran == (4))
{midi=("ost.mid");
txt=("ost.mid")}
if (ran == (5))
{midi=("shark.mid");
txt=("shark.mid")}
/* 
Для Netscape - отключено - надо ? уберите тег комментария..
document.write('<center><embed src="' + midi + '" AUTOSTART=true HIDDEN=false VOLUME=100 WIDTH=200 Height=55 loop=false></embed><br><strong>Эта музыка "<font color="red" size=2><em>' + txt + '</em></font></font>"</strong></center>') 
*/
document.write('<center><bgsound src="' + midi + '" AUTOSTART=true loop=false></bgsound><strong>Эта музыка "<font color="red"><em>' + txt + '</em></font></font>"</strong></center>') 
//--> 
</SCRIPT>

0

123

Фоновая музыка панелью управления и случайным выбором композиции

Код:
<SCRIPT>
//<!-- 
var midi = ""
var txt = ""
var nummidis = 5
day = new Date() 
seed = day.getTime()
ran = parseInt(((seed - (parseInt(seed/1000,10) * 1000))/10)/100*nummidis+ 1,10)
 if (ran == (1))
{midi=("1.mid");}
if (ran == (2))
{midi=("baby.mid");}
if (ran == (3))
{midi=("7.mid");}
if (ran == (4))
{midi=("ost.mid");}
if (ran == (5))
{midi=("shark.mid");}
document.write("<EMBED SRC=" + midi + " width=70 height=28 AUTOSTART=true loop=100 volume=-1000 balance=0");
/*width=70 height=28 -  размиры панели управления loop=100 - количество повторов */
//--> 
</SCRIPT>

0

124

Фоновая музыка панелью управления и случайным выбором композиции (с названием композиции)

Код:
<SCRIPT LANGUAGE="JavaScript">
song = new Array(10);
title = new Array(10);
song[0] ='0.mid'
song[1] ='1.mid'
song[2] ='2.mid'
song[3] ='3.mid'
song[4] ='4.mid'
song[5] ='5.mid'
song[6] ='6.mid'
song[7] ='7.mid'
song[8] ='8.mid'
song[9] ='9.mid'
song[10] ='10.mid'
title[0] = 'Everlong'
title[1] = 'Hey Man Nice Shot'
title[2] = 'Meaning Of Life'
title[3] = 'Polly'
title[4] = 'Fly'
title[5] = 'Damn It'
title[6] = "Short On Ideas"
title[7] = 'Anarchy in the UK'
title[8] = 'Mable'
title[9] = "Sellout"
title[10] = 'You are the Government'
index = Math.floor(Math.random() * song.length);document.write("<DL>\n");
document.write("<EMBED SRC="+song[index]+" width=200 height=28 autostart=true loop=infinite");
/*width=300 height=28 размиры панели управления*/
document.write(' TEXT="#FFFFFF">');
document.write("<font face=arial>");
document.write("Midi: ");
document.write("<font face=arial color=red>");
document.write(title[index]);
document.write("</font>")
document.write("</DL>\n");
</SCRIPT>

0

125

Глаз, следящий за мышкой

Код:
<script language="JavaScript" type="text/javascript">
<!--//
imgp=new Array(9)
function  preload(){
for(c=1;c<=9;c++){
imgp[c]=new Image();}
imgp[1].src="../gif/up-left-e.gif";
imgp[2].src="../gif/up-right-e.gif";
imgp[3].src="../gif/up-right-e.gif";
imgp[4].src="../gif/right-e.gif";
imgp[5].src="../gif/down-right-e.gif";
imgp[6].src="../gif/down-e.gif";
imgp[7].src="../gif/down-left-e.gif";
imgp[8].src="../gif/left-e.gif";
imgp[9].src="../gif/center-e.gif";
}
preload()
function OL(){
if(N=="Microsof"){
A=document.body.clientWidth;
B=document.body.clientHeight;}
if(N=="Netscape"){
A=window.innerWidth;
B=window.innerHeight;}
}
function Mouse(evnt){
N=window.navigator.appName.substring(0,8);
if(N=="Microsof"){x=window.event.x;
y=window.event.y;
B=(document.body.clientWidth/2);}
if(N=="Netscape"){
x=evnt.pageX;
y=evnt.pageY;
B=(window.innerWidth/2)-8;}
if(x<(B-20)&&y<160){
document.images[0].src="../gif/up-left-e.gif"}
if((x>(B-20)&&x<(B+20))&&y<160){
document.images[0].src="../gif/up-right-e.gif"}
if(x>(B+20)&&y<160){
document.images[0].src="../gif/up-right-e.gif"}
if(x>B&&(y>160&&y<200)){
document.images[0].src="../gif/right-e.gif"}
if(x>(B+20)&&y>200){
document.images[0].src="../gif/down-right-e.gif"}
if((x>(B-20)&&x<(B+20))&&y>200){
document.images[0].src="../gif/down-e.gif"}
if(x<(B-20)&&y>200){
document.images[0].src="../gif/down-left-e.gif"}
if(x<B&&(y<200&&y>160)){
document.images[0].src="../gif/left-e.gif"}
if((x<(B+10)&&x>(B-10))&&(y<200&&y>160)){
document.images[0].src="../gif/center-e.gif"}
}
N=window.navigator.appName.substring(0,8);
if(N=="Netscape"){
window.captureEvents(Event.MOUSEMOVE);
window.onmousemove=Mouse}
// -->
</script>
</head>
<body onload="OL()" onmousemove="Mouse()">
<center><IMG alt="" border="0" height="42" src="../gif/center-e.gif" width="106"></center>

другие курсоры

0

126

Выбор цвета фона пользователем

Код:
<form>
<select size=4 name=clr onChange="document.bgColor=this.options[this.selectedIndex].value">
<option value="red">red
<option value="tan">tan
<option value="blue">blue
<option value="lime">lime
<option value="gold">gold
<option value="black" Selected>black
<option value="white">white
<option value="wheat">wheat
<option value="yellow">yellow
<option value="tomato">tomato
<option value="salmon">salmon
<option value="hotpink">hotpink
<option value="darkred">dark red
<option value="turquoise">turquoise
<option value="chocolate">chocolate
<option value="deeppink">deep pink
<option value="darkkhaki">dark khaki
<option value="cadetblue ">cadet blue 
<option value="aquamarine">aquamarine 
<option value="springgreen">springgreen
<option value="darkslateblue">dark slate 
<option value="darksalmon">dark salmon
<option value="darkgoldenrod">dark goldenrod
</select>
</form>

другие фоны

0

127

JavaScript. Позиционирование.

Код:
<script language="JavaScript"> 
<!-- 
var hor=350; 
var ver=150; 
// step = величина шага
var step=10; 
function right () { 
hor+=step; 
if (navigator.appName == "Netscape") 
{ document.move.left = hor } 
else { document.all.move.style.left= hor } 
} 
function left () { 
hor-=step; 
if (navigator.appName == "Netscape") 
{ document.move.left = hor } 
else { document.all.move.style.left= hor } 
} 
function down () { 
ver+=step; 
if (navigator.appName == "Netscape") 
{ document.move.top = ver } 
else { document.all.move.style.top= ver } 
} 
function up () { 
ver-=step; 
if (navigator.appName == "Netscape") 
{ document.move.top = ver } 
else { document.all.move.style.top = ver } 
} 
--> 
</script> 
<body background="bg1.jpg" bgproperties="fixed" style="background-repeat: no-repeat;r"  text="#800000" link="#8000FF" alink="#DC5912" vlink="#9B4E00">
<div id="move" style="position:absolute; left:350px; top:150px;width:120px"><center>
<a href="javascript:up('move');">Вверх</a><br>
<a href="javascript:left('move');">Влево</a>  
<a href="javascript:right('move');">Вправо</a><br>
<a href="javascript:down('move');">Вниз</a>
</center></div>
Код:
<title>JavaScript. Позиционирование.</title>
<script language="JavaScript">
<!--
var hor=0;
var ver=0;
// step = величина шага
var step=20;
function right () {
hor+=step
if (navigator.appName == "Netscape")
{ document.move.left = hor }
else { document.all.move.style.left= hor }
}
function left () {
hor-=step
if (navigator.appName == "Netscape")
{ document.move.left = hor }
else { document.all.move.style.left= hor }
}
function down () {
ver+=step
if (navigator.appName == "Netscape")
{ document.move.top = ver }
else { document.all.move.style.top= ver }
}
function up () {
ver-=step
if (navigator.appName == "Netscape")
{ document.move.top = ver }
else { document.all.move.style.top = ver }
}
function upright () {
ver-=step
hor+=step
if (navigator.appName == "Netscape")
{ document.move.top = ver ;
document.move.left = hor ;}
else { document.all.move.style.top = ver ;
document.all.move.style.left= hor ;}
}
function upleft () {
ver=ver-step
hor=hor-step
if (navigator.appName == "Netscape")
{ document.move.top = ver ;
document.move.left = hor ;}
else { document.all.move.style.top = ver ;
document.all.move.style.left= hor ;}
}
function downleft () {
ver+=step
hor-=step
if (navigator.appName == "Netscape")
{ document.move.top = ver ;
document.move.left = hor ;}
else { document.all.move.style.top = ver ;
document.all.move.style.left= hor ;}
}
function downright () {
ver+=step
hor+=step
if (navigator.appName == "Netscape")
{ document.move.top = ver ;
document.move.left = hor ;}
else { document.all.move.style.top = ver ;
document.all.move.style.left= hor ;}
}
function begin () {
ver=0
hor=0
if (navigator.appName == "Netscape")
{ document.move.top = ver ;
document.move.left = hor ;}
else { document.all.move.style.top = ver ;
document.all.move.style.left= hor ;}
}
// -->
</script>
</head>
<body>
<center><div id="move" style="position:relative; left:0px; top:0px; width:200px; height:50px"><img src="../gif/heart.gif width="33" height="30" border=0></div></center><br><br><br><br><br><br><br><br>
<form><center>
<input type="button" value="Влево-Вверх" onclick="upleft();">
<input type="button" value="Вверх" onclick="up();">
<input type="button" value="Вправо-Вверх" onclick="upright();"><br>
<input type="button" value="Влево" onclick="left();">
<input type="button" value="Исходная позиция" onclick="begin();">
<input type="button" value="Вправо" onclick="right();"><br>
<input type="button" value="Влево-Вниз" onclick="downleft();">
<input type="button" value="Вниз" onclick="down();">
<input type="button" value="Вправо-Вниз" onclick="downright();">
</center></form>

0

128

JavaScript. Позиционирование. Ударяющийся мячик

Код:
<script language="JavaScript">
<!--
var xoff = 200; 
var yoff = 200; 
var inc = 5; 
function move() {
xoff += inc; 
if (xoff>= 600) {inc = -5;}
if (xoff<= 200) {inc = 5;}
ball.top = yoff;
ball.left = xoff;
setTimeout("move()", 50);}
-->
</script>
</head>
<body>
<div id="ball" style="position:absolute;width:10px; height:10px">
<img src="../gif/ball5.gif" width=10 height=10 border=0></div>
<script language="JavaScript">
<!-- 
var NN = (navigator.appName == "Netscape" && parseInt(navigator.appVersion) >= 4);
var ball = (NN) ? document.ball : document.all.ball.style;
move();
-->
</script>

другие мячики

0

129

JavaScript. Позиционирование. Вращение одного объекта вокруг другого по эллипсоидной орбите с прохождением за ним

Код:
<script language="JavaScript"> 
<!-- 
var r = 75; 
var xoff = 450; 
var yoff = 270; 
var pi = Math.PI;  
var inc = pi / 40;  
var pos=0;  
function move() { 
pos += inc;  
if (pos>= 2*pi ) {pos=0 } 
if (pos<= pi) {obj.zIndex =5; } 
if (pos>= pi) {obj.zIndex =0;  } 
obj.left = (r * Math.cos(pos)) + xoff-5 
obj.top = (r *0.15* Math.sin(pos)) + yoff-5; 
setTimeout("move()", 30); 
} 
--> 
</script> 
</head>
<body>
<div id="obj" style="position:absolute; left:400px; top:10px; width:10px; height:31px"><img src="../gif/ball2.gif" width=10 height=10 border=0></div><div style="position:absolute; left:430px; top:248px; width:10px; height:31px"><img src="../gif/heart.gif" width="33" height="30" border=0></div>
<script language="JavaScript"> 
<!--  
var NN = (navigator.appName == "Netscape" && parseInt(navigator.appVersion) >= 4); 
var obj = (NN) ? document.obj : document.all.obj.style; 
move();
--> 
</script>

другие орбиты

0

130

JavaScript. Позиционирование. Преремещающиеся слова.

Код:
<script language="JavaScript"> 
<!-- 
var r = 50; 
var xoff = 450;  
var yoff = 256;  
var pi = Math.PI;  
var inc = pi / 30;  
var pos=0;  
function move() { 
pos += inc;  
obj2.left = -(r * Math.cos(pos)) + xoff-12; 
obj2.top = -(r * Math.sin(pos)*Math.sin(pos)) + yoff; 
obj1.left = (r * Math.cos(pos)) + xoff-35; 
obj1.top = (r * Math.sin(pos)*Math.sin(pos)) + yoff; 
setTimeout("move()", 50); 
} 
--> 
</script> 
</head> 
<body>
<div id="obj1" style="position:absolute;width:70px; height:31px"><font face="Arial" size="3" color="#993333"><b>Script</b></font></div>
<div id="obj2" style="position:absolute; width:70px; height:31px"><font face="Arial" size="3" color="#ff00ff"><b>Java</b></font></div>
<script language="JavaScript"> 
<!--  
var NN = (navigator.appName == "Netscape" && parseInt(navigator.appVersion) >= 4); 
var obj1 = (NN) ? document.obj1 : document.all.obj1.style; 
var obj2 = (NN) ? document.obj2 : document.all.obj2.style; 
move(); 
--> 
</script>

другие передвижения

0

131

Поиск слова или фразы на странице

Код:
<a href="javascript:FD983r={x:function(){var r,i,s=document.selection.createRange().text;if(!s)s=prompt('Найти:','');if(s){r=document.body.createTextRange();for(i=0;r.findText(s);i++){r.execCommand('BackColor','','006600');r.collapse(false)};alert('Найдено: '+i+' слово(а)')}}};FD983r.x()">Найти на этой странице</a>

0

132

Диаграмма

Код:
<script language="JavaScript">
i=0
function d_rand() {
for(j=0;j<10;j++) { 
for(i=0;i<10;i++) document.images[j+i*10].src = "white.jpg"
y= Math.floor(Math.random()*10)
for(i=9;i>9-y;i--) document.images[j+i*10].src = "blue.jpg"
}
}
</script>

0

133

Органайзер

Код:
<script LANGUAGE="Javascript">
<!--
var caution = false
function setCookie(name, value, expires, path, domain, secure) {
var curCookie = name + "=" + escape(value) +
((expires) ? "; expires=" + expires.toGMTString() : "") +
((path) ? "; path=" + path : "") +
((domain) ? "; domain=" + domain : "") +
((secure) ? "; secure" : "")
if (!caution || (name + "=" + escape(value)).length <= 4000)
document.cookie = curCookie
else
if (confirm("Cookie превышает 4KB и будет вырезан !"))
document.cookie = curCookie
}
function getCookie(name) {
var prefix = name + "="
var cookieStartIndex = document.cookie.indexOf(prefix)
if (cookieStartIndex == -1)
return null
var cookieEndIndex = document.cookie.indexOf(";", cookieStartIndex + prefix.length)
if (cookieEndIndex == -1)
cookieEndIndex = document.cookie.length
return unescape(document.cookie.substring(cookieStartIndex + prefix.length, cookieEndIndex))
}
function deleteCookie(name, path, domain) {
if (getCookie(name)) {
document.cookie = name + "=" + 
((path) ? "; path=" + path : "") +
((domain) ? "; domain=" + domain : "") +
"; expires=Thu, 01-Jan-70 00:00:01 GMT"
}
}
function fixDate(date) {
var base = new Date(0)
var skew = base.getTime()
if (skew > 0)
date.setTime(date.getTime() - skew)
}
function initCookie(monthName) {
var text = ""
for (var i = 1; i <= 31; ++i) {
text += "^" + i + "^"
}
var now = new Date()
fixDate(now)
now.setTime(now.getTime() + 1000 * 60 * 60 * 24 * 31)
setCookie(monthName + "Calendar", text, now)
}
function getSpecificReminder(num, monthName) {
var prefix = "^" + num + "^"
var totalCookie = getCookie(monthName + "Calendar")
var startIndex = totalCookie.indexOf(prefix, 0)
var startData = totalCookie.indexOf("^", startIndex + 1) + 1
if (num == 31)
var endData = totalCookie.length
else
var endData = totalCookie.indexOf("^", startData)
return totalCookie.substring(startData, endData)
}
function setSpecificReminder(num, monthName, newValue) {
var prefix = "^" + num + "^"
var totalCookie = getCookie(monthName + "Calendar")
var startIndex = totalCookie.indexOf(prefix, 0)
var startData = totalCookie.indexOf("^", startIndex + 1) + 1
if (num == 31)
var endData = totalCookie.length
else
var endData = totalCookie.indexOf("^", startData)
var now = new Date()
fixDate(now)
now.setTime(now.getTime() + 1000 * 60 * 60 * 24 * 31)
setCookie(monthName + "Calendar", totalCookie.substring(0, startData) + newValue + totalCookie.substring(endData, totalCookie.length), now)
}
function getInput(num, monthName) {
if (!getCookie(monthName + "Calendar")) 
initCookie(monthName)
var newValue = prompt("Введите запись соответствующей данной дате:", getSpecificReminder(num, monthName))
if (newValue) 
setSpecificReminder(num, monthName, newValue)
}
function getTime() {
var now = new Date()
var hour = now.getHours()
var minute = now.getMinutes()
now = null
var ampm = "" 
if (hour >= 12) {
hour -= 12
ampm = "PM"
} else
ampm = "AM"
hour = (hour == 0) ? 12 : hour
if (minute < 10)
minute = "0" + minute 
return hour + ":" + minute + " " + ampm
}
function leapYear(year) {
if (year % 4 == 0) 
return true 
return false 
}
function getDays(month, year) {
var ar = new Array(12)
ar[0] = 31 // January
ar[1] = (leapYear(year)) ? 29 : 28 // February
ar[2] = 31 // March
ar[3] = 30 // April
ar[4] = 31 // May
ar[5] = 30 // June
ar[6] = 31 // July
ar[7] = 31 // August
ar[8] = 30 // September
ar[9] = 31 // October
ar[10] = 30 // November
ar[11] = 31 // December
// return number of days in the specified month (parameter)
return ar[month]
}
function getMonthName(month) {
// create array to hold name of each month
var ar = new Array(12)
ar[0] = "ЯНВАРЬ"
ar[1] = "ФЕВРАЛЬ"
ar[2] = "МАРТ"
ar[3] = "АПРЕЛЬ"
ar[4] = "МАЙ"
ar[5] = "ИЮНЬ"
ar[6] = "ИЮЛЬ"
ar[7] = "АВГУСТ"
ar[8] = "СЕНТЯБРЬ"
ar[9] = "ОКТЯБРЬ"
ar[10] = "НОЯБРЬ"
ar[11] = "ДЕКАБРЬ"
// return name of specified month (parameter)
return ar[month]
}
function setCal() {
// standard time attributes
var now = new Date()
var year = now.getYear()
var month = now.getMonth()
var monthName = getMonthName(month)
var date = now.getDate()
now = null
// create instance of first day of month, and extract the day on which it occurs
var firstDayInstance = new Date(year, month, 1)
var firstDay = firstDayInstance.getDay()
firstDayInstance = null
// number of days in current month
var days = getDays(month, year)
// call function to draw calendar
drawCal(firstDay + 1, days, date, monthName, 1900 + year)
}
function drawCal(firstDay, lastDate, date, monthName, year) {
// constant table settings
var headerHeight = 35 // height of the table's header cell
var border = 0 // 3D height of table's border
var cellspacing = 0 // width of table's border
var headerColor = "Black" // color of table's header
var headerSize = "+2" // size of tables header font
var colWidth = 45 // width of columns in table
var dayCellHeight = 15 // height of cells containing days of the week
var dayColor = "White" // color of font representing week days
var cellHeight = 25 // height of cells representing dates in the calendar
var todayColor = "red" // color specifying today's date in the calendar
var timeColor = "Black" // color of font representing current time
var dayCellcolor="0066ff"
var monthColor="00ccff"
// create basic table structure
var text = "" // initialize accumulative variable to empty string
text += '<CENTER>'
text += '<TABLE BORDER=' + border + ' CELLSPACING=' + cellspacing + '>' // table settings
text += 	'<TH COLSPAN=7 HEIGHT=' + headerHeight + ' BGCOLOR='+ monthColor +'>' // create table header cell
text +=     '<FONT COLOR="' + headerColor + '" SIZE=' + headerSize + '>' // set font for table headertext +=     	monthName + ' ' + year 
text +=     '</FONT>' // close table header's font settings
text += 	'</TH>' // close header cell
// variables to hold constant settings
var openCol = '<TD align=right WIDTH=' + colWidth + ' HEIGHT=' + dayCellHeight + ' BGCOLOR='+ dayCellcolor +'>'
openCol += '<FONT SIZE=-1 COLOR="' + dayColor + '">'
var closeCol = '</FONT></TD>'
// create array of abbreviated day names
var weekDay = new Array(7)
weekDay[0] = "Вс"
weekDay[1] = "Пн"
weekDay[2] = "Вт"
weekDay[3] = "Ср"
weekDay[4] = "Чт"
weekDay[5] = "Пт"
weekDay[6] = "Сб"
// create first row of table to set column width and specify week day
text += '<TR ALIGN="center" VALIGN="center">'
for (var dayNum = 0; dayNum < 7; ++dayNum) {
text += openCol + weekDay[dayNum] + closeCol 
}
text += '</TR>'
// declaration and initialization of two variables to help with tables
var digit = 1
var curCell = 1
for (var row = 1; row <= Math.ceil((lastDate + firstDay - 1) / 7); ++row) {
text += '<TR ALIGN="right" VALIGN="top">'
for (var col = 1; col <= 7; ++col) {
if (digit > lastDate)
break
if (curCell < firstDay) {
text += '<TD></TD>';
curCell++
} else {
if (digit == date) { // current cell represent today's date
text += '<TD HEIGHT=' + cellHeight + ' BGCOLOR="#ffccff">'
text += '<FONT COLOR="' + todayColor + '">'
text += '<A HREF="javascript:getInput(' + digit + ', \'' + monthName + '\')" onMouseOver="window.status = \'Записать или прочесть запись за ' + monthName + ' ' + digit + '\'; return true"><FONT SIZE=-1 COLOR="' + todayColor + '">' + digit + '</FONT></A>'
text += '<BR>'
text += '<FONT COLOR="' + timeColor + '" SIZE=2>'
text += '<CENTER>' + getTime() + '</CENTER>'
text += '</FONT>'
text += '</TD>'
} else
text += '<TD HEIGHT=' + cellHeight + ' BGCOLOR="#ccccff"><FONT SIZE=-1><A HREF="javascript:getInput(' + digit + ', \'' + monthName + '\')" onMouseOver="window.status = \'Записать или прочесть запись за ' + monthName + ' ' + digit + '\'; return true">' + digit + '</A></FONT></TD>'
digit++
}
}
text += '</TR>'
}
// close all basic table tags
text += '</TABLE>'
text += '</CENTER>'
// print accumulative HTML string
document.write(text) 
}
setCal()
// -->
</script>

0

134

Выпадающее меню

Код:
<style type="text/css">
@import ../style1.css;
#hardButton {position: absolute; z-index: 80; left: 150px; top: 20px;} 
#hardMenu {position: absolute; z-index: 70; visibility: hidden; left: 150px; top: 40px;} 
</style>
<title>Коллекция Java скриптов. Библиотека JavaScript в примерах. Выпадающее меню на Javascript.</title>
</head>
<body bgcolor="000000" text="#00ff99" link="#00ff00" alink="#99ff00" vlink="#00cc00" onLoad="init()">
<script language="JavaScript" src="minu.js"></script>
<div id="hardButton" >
<a href="javascript:showHideLayerSwitch('hardMenu');"><strong>JavaScript</strong></a>
</div> 
<div id="hardMenu"> 
<table width="130" border="0" bgcolor="#006600">
<tr>
<td>
<font face="arial" size="-2"><br> 
<a target="_top" href="../window.htm"><img height="10" src="../gif/ball1.gif" width="10" border="0"> Дополнительные окна</a><br>
<a target="_top" href="../infill.htm"><img height=10 src="../gif/ball1.gif" width=10 border=0> Заполнение форм</a><br>
<a target="_top" href="../game.htm"><img height=10 src="../gif/ball1.gif" width=10 border=0> Игры</a><br>
<a target="_top" href="../clock.htm"><img height="10" src="../gif/ball1.gif" width="10" border="0"> Календари и часики</a><br>
<a target="_top" href="../picture.htm"><img height=10 src="../gif/ball1.gif" width=10 border=0> Картинки</a><br>
<a target="_top" href="../linki.htm"><img height="10" src="../gif/ball1.gif" width="10" border="0"> Кнопки</a><br>
<a target="_top" href="../writ.htm"><img height="10" src="../gif/ball1.gif" width="10" border="0"> Надписи</a><br>
<a target="_top" href="../background.htm"><img height=10 src="../gif/ball1.gif" width=10 border=0> Оформление фона</a><br>
<a target="_top" href="../object.htm"><img height="10" src="../gif/ball1.gif" width="10" border="0"> Передвижение объекта</a><br>
<a target="_top" href="../ball.htm"><img height="10" src="../gif/ball1.gif" width="10" border="0"> Передвижение мячика</a><br>
<a target="_top" href="../orbit.htm"><img height="10" src="../gif/ball1.gif" width="10" border="0"> Передвижение по орбите</a><br>
<a target="_top" href="../term.htm"><img height="10" src="../gif/ball1.gif" width="10" border="0"> Передвижение слов</a><br>
<a target="_top" href="../useful.htm"><img height="10" src="../gif/ball1.gif" width="10" border="0"> Полезное для сайтов</a><br>
<a target="_top" href="../frame.htm"><img height="10" src="../gif/ball1.gif" width="10" border="0"> Полезное для сайтов с фреймами</a><br>
<a target="_top" href="various.htm"><img height="10" src="../gif/ball1.gif" width="10" border="0"> Разные скрипты</a><br>
<a target="_top" href="minu.htm"><img height="10" src="../gif/ball1.gif" width="10" border="0"> Сложные меню</a><br>
<a target="_top" href="linki.htm"><img height="10" src="../gif/ball1.gif" width="10" border="0"> Ссылки</a><br>
</font>
</td>
</tr>
</table> 
</div>

Сохраните этот текст как файл с именем minu и расширением js, в ту же директорию что и файлы, содержащие данное меню.

Код:
var visibleVar="null"; function init(){ if (navigator.appName == "Netscape") { layerRef="document.layers"; styleSwitch=""; visibleVar="show"; }else{ layerRef="document.all"; styleSwitch=".style"; visibleVar="visible"; } } function showHideLayerSwitch(layerName){ if (eval(layerRef+'["'+layerName+'"]'+styleSwitch+'.visibility == visibleVar')){ hideLayer(layerName); }else{ showLayer(layerName); } } function showLayer(layerName){ eval(layerRef+'["'+layerName+'"]'+styleSwitch+'.visibility="visible"'); } function hideLayer(layerName){ eval(layerRef+'["'+layerName+'"]'+styleSwitch+'.visibility="hidden"'); }

0

135

Выпадающее многоуровневое меню с абсолютным значением положения

Код:
<link rel=stylesheet href="menu.css" type="text/css">
<script language="javascript" src="menu.js"></script>
<script language="javascript" src="sample.js"></script>
</head>
<body bgcolor="000000" text="#00ff99" link="#00ff00" alink="#99ff00" vlink="#00cc00" onload="buildMenu('myMenu',150,50);">

Сохраните этот текст как файл с именем menu и расширением js, в ту же директорию что и файлы, содержащие данное меню.

Код:
// Script begins

var isIE4 = false;
var isNN4 = false;

var flagMenu = "M";
var flagLink = "L";
var flagCommand = "C";
var flagSeparator = "S";

var charWidth = 7; // character width
var charHeight = 18; // character height
var colorNormal = "#cccccc"; // menu pad color
var colorHighlighted = "#ffffff"; // menu highlighted item color
var colorTopLine = "#999999"; // separator upper line color
var colorBottomLine = "#ffffff"; // separator lower line color

var borderSize = 1;
var marginSize = 4;
var marginString = "  ";
var subMenuFlagSize = 4;

var menuItemCount = -1;
var menuItem = new Array();
var menuFolderCount = -1;
var menuFolder = new Array();
var menuFolderSwitch = new Array();
var menuWidth = new Array();
var itemLayer = new Array();
var menuLayer = new Array();
var menuDone = new Array();

var itemOn = false;
var nnWidth = 0, nnHeight = 0;

function launchCommand(commandString) {
  // eval(commandString);
  alert(commandString);
}

function launchPage(pageURL) {
  document.location.assign(pageURL);
  //alert(pageURL);
}

function clickMenu(itemIndex) {
  var menuIndex = menuItem[itemIndex].myFolder;
  var folderIndex = menuItem[itemIndex].folder;
  var itemX = menuItem[itemIndex].x;
  var itemY = menuItem[itemIndex].y;

  if (menuItem[itemIndex].type == flagMenu) {
    if (menuFolderSwitch[folderIndex])
      hideMenu(folderIndex)
    else
      showMenu(folderIndex,itemX + menuWidth[menuIndex] * charWidth + subMenuFlagSize,itemY);
  }
  else if (menuItem[itemIndex].type == flagLink) {
    hideSubMenu();
    launchPage(menuItem[itemIndex].url);
  }
  else if (menuItem[itemIndex].type == flagCommand) {
    hideSubMenu();
    launchCommand(menuItem[itemIndex].command);
  }
}

function mouseOver() {
  var itemIndex = this.itemIndex;
  var menuIndex = menuItem[itemIndex].myFolder;
  var menuLength = menuFolder[menuIndex].length;
  var folderIndex = menuItem[itemIndex].folder;
  var itemX = menuItem[itemIndex].x;
  var itemY = menuItem[itemIndex].y;
  var thisFolder = 0;
  var thisItem = 0;

  itemOn = true;

  if (menuItem[itemIndex].type != flagSeparator) {
    if (isIE4) {
      this.style.backgroundColor = colorHighlighted;
    }
    else if (isNN4) {
      this.document.bgColor = colorHighlighted;
    }
  }

  for (var i = 0; i < menuLength; i++) {
    thisItem = menuFolder[menuIndex][i];

    if (thisItem != itemIndex)
      if (menuItem[thisItem].type == flagMenu) {
        thisFolder = menuItem[thisItem].folder;

        if (menuFolderSwitch[thisFolder])
          hideMenu(thisFolder);
      }
  }

  if (menuItem[itemIndex].type == flagMenu)
    if (!menuFolderSwitch[folderIndex])
      showMenu(folderIndex,itemX + menuWidth[menuIndex] * charWidth + subMenuFlagSize,itemY);

  window.status = menuItem[itemIndex].description;
  return true;
}

function mouseOut() {
  itemOn = false;

  if (isIE4)
    this.style.backgroundColor = colorNormal
  else if (isNN4)
    this.document.bgColor = colorNormal;

  window.status = "";
}

function menuItemUnit() {
  this.type = "";
  this.name = "";
  this.description = "";
  this.url = "";
  this.command = "";
  this.menu = "";
  this.folder = -1;
  this.myFolder = -1;
  this.x = -1;
  this.y = -1;
}

function readMenu(menuName) {
  var menu = eval(menuName);
  var menuLength = menu.length
  var thisFolder = ++menuFolderCount;

  menuFolder[thisFolder] = new Array();
  menuFolderSwitch[thisFolder] = false;
  menuWidth[thisFolder] = 0;
  menuLayer[thisFolder] = false;
  menuDone[thisFolder] = false;

  for (var i = 0; i < menuLength; i++) {
    menuFolder[thisFolder][i] = ++menuItemCount;
    itemLayer[menuItemCount] = false;

    menuItem[menuItemCount] = new menuItemUnit();
    menuItem[menuItemCount].myFolder = thisFolder;
    menuItem[menuItemCount].type = menu[i][0];
    menuItem[menuItemCount].name = menu[i][1];
    menuItem[menuItemCount].description = menu[i][2];

    if (menuWidth[thisFolder] < (menuItem[menuItemCount].name.length + marginSize))
      menuWidth[thisFolder] = menuItem[menuItemCount].name.length + marginSize;

    if (menuItem[menuItemCount].type == flagMenu) {
      menuItem[menuItemCount].menu = menu[i][3];
      menuItem[menuItemCount].folder = menuFolderCount + 1;
      readMenu(menuItem[menuItemCount].menu);
    }
    else if (menuItem[menuItemCount].type == flagLink) {
      menuItem[menuItemCount].url = menu[i][3];
    }
    else if (menuItem[menuItemCount].type == flagCommand) {
      menuItem[menuItemCount].command = menu[i][3];
    }
    else if (menuItem[menuItemCount].type != flagSeparator) {
      alert("Menu Error");
    }
  }
}

function getItem(itemIndex,itemDimX,itemDimY,menuIndex) {
  var thisItem = null;
  var subMenuFlag = (menuItem[itemIndex].type == flagMenu)?"subMenu.gif":"onePixel.gif";
  var singleQuote = "'";
  var itemID = "item" + itemIndex + "";
  var layerString = '<div id="' + itemID + '" style="position:absolute; width:' + itemDimX + '; background-color:' + colorNormal + '; visibility:hidden;"></div>';
  var htmlString = (menuItem[itemIndex].type == flagSeparator)?('<table width=' + itemDimX +' height=2 cellpadding=0 cellspacing=0 border=0><tr align=left valign=bottom><td bgcolor=' + colorTopLine + '><img src="onePixel.gif" width=1 height=1 border=0></td></tr><tr align=left valign=top><td bgcolor=' + colorBottomLine + '><img src="onePixel.gif" width=1 height=1 border=0></td></tr></table>'):('<table width=' + itemDimX +' height=' + itemDimY + ' cellpadding=0 cellspacing=0 border=0><tr align=left valign=middle><td nowrap><span id="menuText"><a class="menu" href="javascript:clickMenu(' + itemIndex + ')" onMouseOver="window.status=' + singleQuote + menuItem[itemIndex].description + singleQuote + ';return true;">' + marginString + menuItem[itemIndex].name + marginString + '</a></span></td><td><img src="' + subMenuFlag + '" width=4 height=7 border=0 align=right></td></tr></table>');

  if (!itemLayer[itemIndex]) {
    itemLayer[itemIndex] = true;

    if (isIE4) {
      document.body.insertAdjacentHTML("BeforeEnd",layerString);
      thisItem = document.all[itemID];

      thisItem.innerHTML = htmlString;
      thisItem.style.zIndex = menuIndex * 2 + 1;

      thisItem.onmouseover = mouseOver;
      if (menuItem[itemIndex].type != flagSeparator)
        thisItem.onmouseout = mouseOut;

      thisItem.itemIndex = itemIndex;
    }
    else if (isNN4) {
      document.layers[itemID] = new Layer(itemDimX);
      thisItem = document.layers[itemID];

      thisItem.visibility = "hidden";
      thisItem.document.open();
      thisItem.document.writeln(htmlString);
      thisItem.document.close();
      thisItem.document.bgColor = colorNormal;
      thisItem.zIndex = menuIndex * 2 + 1;

      thisItem.onmouseover = mouseOver;
      if (menuItem[itemIndex].type != flagSeparator)
        thisItem.onmouseout = mouseOut;

      thisItem.itemIndex = itemIndex;
    }
  }

  return itemID;
}

function getMenu(menuIndex,menuDimX,menuDimY) {
  var menuID = "menu" + menuIndex + "";
  var menuPadX = menuDimX + borderSize * 2;
  var menuPadY = menuDimY + borderSize * 2;
  var layerString = '<div id="' + menuID + '" style="position:absolute; width:' + menuPadX + '; visibility:hidden;"></div>';
  var htmlString = '<table width=' + menuPadX +' height=' + menuPadY + ' cellpadding=0 cellspacing=0 border=' + borderSize + '><tr align=left valign=middle><td></td></tr></table>';

  if (!menuLayer[menuIndex]) {
    menuLayer[menuIndex] = true;

    if (isIE4) {
      document.body.insertAdjacentHTML("BeforeEnd",layerString);

      document.all[menuID].innerHTML = htmlString;
      document.all[menuID].style.zIndex = menuIndex * 2;
    }
    else if (isNN4) {
      document.layers[menuID] = new Layer(menuPadX);

      document.layers[menuID].visibility = "hidden";
      document.layers[menuID].zIndex = menuIndex * 2;
      document.layers[menuID].document.open();
      document.layers[menuID].document.writeln(htmlString);
      document.layers[menuID].document.close();
    }
  }

  return menuID;
}

function showLayer(layerID) {
  if (isIE4)
    document.all[layerID].style.visibility = "visible"
  else if (isNN4)
    document.layers[layerID].visibility = "show";
}

function hideLayer(layerID) {
  if (isIE4)
    document.all[layerID].style.visibility = "hidden"
  else if (isNN4)
    document.layers[layerID].visibility = "hidden";
}

function moveLayerTo(layerID,x,y) {
  if (isIE4) {
    document.all[layerID].style.pixelLeft = x;
    document.all[layerID].style.pixelTop = y;
  }
  else if (isNN4) {
    document.layers[layerID].left = x;
    document.layers[layerID].top = y;
  }
}

function hideMenu(menuIndex) {
  var menuLength = menuFolder[menuIndex].length;
  var menuID = getMenu(menuIndex,0,0);
  var itemID = "";
  var itemIndex = 0;

  for (var i = 0; i < menuLength; i++) {
    itemIndex = menuFolder[menuIndex][i];

    if (menuItem[itemIndex].type == flagMenu)
      if (menuFolderSwitch[menuItem[itemIndex].folder])
        hideMenu(menuItem[itemIndex].folder);

    itemID = getItem(itemIndex,0,0,0);
    hideLayer(itemID);
  }

  hideLayer(menuID);

  menuFolderSwitch[menuIndex] = false;
}

function hideSubMenu() {
  var menuLength = menuFolder[0].length;

  for (var i = 0; i < menuLength; i++) {
    itemIndex = menuFolder[0][i];

    if (menuItem[itemIndex].type == flagMenu) {
      if (menuFolderSwitch[menuItem[itemIndex].folder])
        hideMenu(menuItem[itemIndex].folder);
    }
  }
}

function showMenu(menuIndex,menuX,menuY) {
  var itemDimY = menuY;
  var menuLength = menuFolder[menuIndex].length;
  var menuDimX = menuWidth[menuIndex] * charWidth + subMenuFlagSize;
  var menuID = "";
  var itemID = "";
  var itemIndex = 0;

  if (!menuDone[menuIndex]) {
    for (var i = 0; i < menuLength; i++) {
      itemIndex = menuFolder[menuIndex][i];

      menuItem[itemIndex].x = menuX;
      menuItem[itemIndex].y = itemDimY;
      itemDimY +=  (menuItem[itemIndex].type != flagSeparator)?charHeight:2;

      itemID = getItem(itemIndex,menuDimX,charHeight,menuIndex);

      moveLayerTo(itemID,menuItem[itemIndex].x,menuItem[itemIndex].y);
    }

    menuID = getMenu(menuIndex,menuDimX,itemDimY-menuY);
    moveLayerTo(menuID,menuX-borderSize,menuY-borderSize);

    menuDone[menuIndex] = true;
  }

  for (var i = 0; i < menuLength; i++)
    showLayer(getItem(menuFolder[menuIndex][i],0,0,0));

  showLayer(getMenu(menuIndex,0,0));

  menuFolderSwitch[menuIndex] = true;
}

function buildMenu(menuName,x,y) {
  isIE4 = document.all;
  isNN4 = document.layers;

  if (isIE4 || isNN4) {
    if (isNN4) {
      nnWidth = window.innerWidth;
      nnHeight = window.innerHeight;
      window.onResize = reloadMenu;
    }

    readMenu(menuName);
    showMenu(0,x,y);
    captureClick();
  }
}

function switchMenu(e) {
  if (!itemOn)
    hideSubMenu();

  if (isNN4) {
    routeEvent(e);
  }

  return true;
}

function captureClick() {
  if (isIE4)
    document.onclick = switchMenu;
  else {
    document.onClick = switchMenu;
    document.captureEvents(Event.CLICK);
  }
}

function reloadMenu() {
  if (nnWidth != window.innerWidth || nnHeight != window.innerHeight)
    document.location.reload();
}

// Script ends

Это файл содержит текст ссылки, ее описание в строке статуса и саму ссылку. Сделав свой файл, сохраните его с именем sample и расширением js в той же директории. База может быть сгенерирована генератором баз данных для многоуровневых меню

Код:
var myMenu = new Array();
myMenu[0] = new Array("M","HTML","this is the first sub menu","menu1");
myMenu[1] = new Array("M","CSS","Описание как сделать сайт красивее и привлекательнее","menu2");
myMenu[2] = new Array("S","","","");
myMenu[3] = new Array("L","Scriptic.narod.ru","JavaScript, CSS и HTML на халяву","http://scriptic.narod.ru/");
myMenu[4] = new Array("L","GLidia.narod.ru","Персональный сайт создательницы сайта Scriptic.narod.ru","http://glidia.narod.ru");
myMenu[5] = new Array("M","Java-скрипты","Огромная коллекция для свободного использования","menu3");
myMenu[6] = new Array("S","","","");
myMenu[7] = new Array("L","Гостевая","Напишите о достоинствах или недостатках","http://narod.yandex.ru/guestbook/?owner=3083811&mainhtml=gosti.txt&messageshtml=style.txt");

var menu1 = new Array();
menu1[0] = new Array("L","Спецсимволы HTML","Таблица спецсимволов HTML","../html/symbol.htm");
menu1[1] = new Array("S","","","");
menu1[2] = new Array("L","Основные тэги HTML","Таблица основных тэгов HTML и их атрибутов","../html/teg.htm");
menu1[3] = new Array("L","Таблица цветов","RBG-палитра 216 цветов","../html/color1.htm");

var menu2 = new Array();
menu2[0] = new Array("L","Полосы прокрутки","Изменение цвета полос прокрутки","../css/scroling.htm");
menu2[1] = new Array("L","Изменение вида курсора","Изменение вида курсора на один из стандартных","../css/vidcursor.htm");
menu2[2] = new Array("S","","","");
menu2[3] = new Array("L","Введение в CSS","Введение в CSS (рекомендую прочитать новичкам)","../css/css4.htm");

var menu3 = new Array();
menu3[0] = new Array("L","Музыка","Музыкальные шкатулки (не забудьте включить колонки)","../muz.htm");
menu3[1] = new Array("M","Игры","Морской бой, Пятнашки, Шарики, Шашки, Linse","menu11");
menu3[2] = new Array("S","","","");
menu3[3] = new Array("L","Ссылки","Различные эффекты применяемые к ссылкам","../linki.htm");

var menu11 = new Array();
menu11[0] = new Array("L","Морской бой","Морской бой","../game/more.htm");
menu11[1] = new Array("L","Пятнашки","Пятнашки","../game/fift/fift.htm");
menu11[2] = new Array("L","Шарики","Шарики","../game/bubble/bubble.htm");
menu11[3] = new Array("L","Шашки","Шашки","../game/checkers.htm");
menu11[4] = new Array("L","Linse","Linse","../game/linse/linse.htm");

Сохраните этот текст, как файл с именем menu и расширением css, в ту же директорию, что и файлы, содержащие данное меню.

Код:
a.menu {text-decoration:none; color:#000000}
#menuText {font-size:12px; color:#000000; font-family:arial,verdana,courier,times;}

0

136

Выпадающее при двойном клике в любом месте многоуровневое меню

Код:
<script language="JavaScript" src="klicmenu.js"></script>
</HEAD>
<body bgcolor="#000000" text="#00ff99" link="#00ff00" alink="#99ff00" vlink="#00cc00" onLoad="openandclose(1000)">
<iframe src="../menu.htm" align="left" width="140" height="560" scrolling="no" frameborder="0"></iframe>
Кликните два раза мышью в любом месте для появления меню.
<div id="menu" style="position:absolute;top:20px;left:10px;visibility:hidden;"></div>

Сохраните этот текст как файл с именем klicmenu и расширением js, в ту же директорию что и файлы, содержащие данное меню.

Код:
<!-- 
//При желании сделать дополнительные основные ссылки меняйте значение menublock[x] на следующую цифру 
//Вы можете ставить ссылки и относительные и полные, изменять значение target.
//*Внимание после | не должно быть пробелов запись "Linse| ../game/linse/linse.htm| _top;" будет неверной и станет причиной ошибок *//
// после последней дополнительной ссылки каждого блока не должно быть знака "+"
var menublock=new Array() 
var plus_i=0 
menublock[0]="Arial;"+    // font mainlink
	// Цвет основной ссылки
    "1;"+    // fontsize mainlink 
	//размер основной ссылки
    "ffff00;"+   // fontcolor mainlink
	// Цвет основной ссылки
    "1;"+    // fontweight mainlink, 1 means bold, 0 means normal
    "Arial;"+   // font sublinks
	// Шрифт дополнительной ссылки
    "1;"+    // fontsize sublinks
	// Размер дополнительной ссылки
    "00ff00;"+   // fontcolor sublinks
	// Цвет дополнительной ссылки
    "0;"+    // fontweight sublinks, 1 means bold, 0 means normal
    "Дополнительные окна|#|;"+ // text|URL|target of mainlink
    "Дополнительное окно приветствия|../win/window12.htm|_top;"+  // text|URL|target of first sublink
    "Дополнительное окно прощания|../win/window14.htm|_top;"   // text|URL|target of second sublink  
    
menublock[1]="Arial;"+   // font mainlink
    "1;"+    // fontsize mainlink
    "ffff00;"+   // fontcolor mainlink
    "1;"+    // fontweight mainlink, 1 means bold, 0 means normal
    "Arial;"+   // font sublinks
    "1;"+    // fontsize sublinks
    "00ff00;"+   // fontcolor sublinks
    "0;"+    // fontweight sublinks, 1 means bold, 0 means normal
    "Игры|#|;"+         // text and URL of first mainlink
    "Игровой автомат|../game/bandit/notrun.htm|_top;"+ // text|URL|target of mainlink
    "Морской бой|../game/more.htm|_top;"+ // text|URL|target of first sublink
    "Пятнашки|../game/fift/fift.htm|_top;"+ // text|URL|target of second sublink 
    "Шарики|../game/bubble/bubble.htm|_top;"+ // text|URL|target of thirth sublink 
    "Шашки|../game/checkers.htm|_top;"+  // text|URL|target of fourth sublink 
	"Linse|../game/linse/linse.htm|_top;"   // text|URL|target of fourth sublink 

    
menublock[2]="Arial;"+      // font mainlink
    "1;"+    // fontsize mainlink
    "ffff00;"+   // fontcolor mainlink
    "1;"+    // fontweight mainlink, 1 means bold, 0 means normal
    "Arial;"+   // font sublinks
    "1;"+    // fontsize sublinks
    "00ff00;"+   // fontcolor sublinks
    "0;"+    // fontweight sublinks, 1 means bold, 0 means normal
    "Ссылки|#|;"+         // text and URL of mainlink
    "Печатающиеся ссылки|../link/linkpech.htm|_top;"+   // text and URL of thirth sublink  
    "Салют при наведении на ссылку|../link/linksalut.htm|_top;"+ // text and URL of first sublink
    "Смена текста ссылки при наведении курсора|../link/hgnglink.htm|_top;" // text and URL of second sublink
 
// The following block is different. It contains a mainlink without submenus.
// Take care to set the ";;;;" exactly as seen below.
menublock[3]="Arial;"+   // font mainlink
    "1;"+    // fontsize mainlink
    "ffff00;"+   // fontcolor mainlink
 "1;"+    // fontweight mainlink, 1 means bold, 0 means normal
 ";;;;"+       // leave it empty
    "HOME|../|_top;"   //* "Текст|URL| место отрытия ссылки (значение target)" *//
    
//* Цвет фона меню (шестизначный код или английское название)*//  
var bgmenu="006600"

//* Ширина меню в пикселях (pixels)*//
var widthmenu=150
    
// No need to change anything below  
//  ******************************************************
var menusplit
var urlsplit
var font_weight_main
var font_weight_sub
var font_weight_sub
var showmenu=1
var x,y

var minusimg=new Image()
minusimg.src="../gif/arrow_green.gif"

var plusimg=new Image()
plusimg.src="../gif/arrow_red.gif"
    
var showsubmenus=new Array()
for (i=0;i<=menublock.length-1;i++) {
 showsubmenus[i]=-1
}

var plusminusimg=new Array()
for (i=0;i<=menublock.length-1;i++) {
 plusminusimg[i]=plusimg.src
}

function openandclose(visi) {
 showsubmenus[visi]=(-1)*showsubmenus[visi]
    var menucontent=""
    if (showsubmenus[visi]==1) {plusminusimg[visi]=minusimg.src}
    if (showsubmenus[visi]==-1) {plusminusimg[visi]=plusimg.src}
    menucontent+="<table border=0 cellspacing=0  width="+widthmenu+">"
 for (i=0;i<=menublock.length-1;i++) {
  menusplit=menublock[i].split(";")
  urlsplit=menusplit[8].split("|")
  if (menusplit[3]==1) {font_weight_main="<b>"}
  if (menusplit[3]==0) {font_weight_main=""}
  if (menusplit[7]==1) {font_weight_sub="<b>"}
  if (menusplit[7]==0) {font_weight_sub=""} 
  menucontent+="<tr><td bgcolor="+bgmenu+">"
       if (menusplit[9].length==0) {
menucontent+="&nbsp;</td>"
menucontent+="<td bgcolor="+bgmenu+">"
menucontent+=font_weight_main
menucontent+="<a href="+urlsplit[1]+" target="+urlsplit[2]+">"
menucontent+="<font face="+menusplit[0]+" color="+menusplit[2]+" size="+menusplit[1]+">"
menucontent+=urlsplit[0]
menucontent+="</font></a></td></tr>"
plus_i++ 
        }
        
        if (menusplit[9].length!=0) {
var thismainmenu=i+plus_i
menucontent+="<a href='javascript:openandclose("+i+")'>"
menucontent+="&nbsp;&nbsp;<img src='"+plusminusimg[i]+"' border=0></a></td>"
menucontent+="<td bgcolor="+bgmenu+">"
menucontent+=font_weight_main
menucontent+="<a href='javascript:openandclose("+i+")'>"
menucontent+="<font face="+menusplit[0]+" color="+menusplit[2]+" size="+menusplit[1]+">"
menucontent+=urlsplit[0]
menucontent+="</font></a></td></tr>"
   
      if (showsubmenus[i]==1) {
       for (ii=9;ii<=menusplit.length-1;ii++) {
        urlsplit=menusplit[ii].split("|")
        menucontent+="<tr><td bgcolor="+bgmenu+">&nbsp;</td><td bgcolor="+bgmenu+">"
           menucontent+=font_weight_sub
        menucontent+="<a href="+urlsplit[1]+" target="+urlsplit[2]+">"
        menucontent+="<font face="+menusplit[4]+" color="+menusplit[6]+" size="+menusplit[5]+">"
        menucontent+=urlsplit[0]
        menucontent+="</font></a>&nbsp;</td></tr>"
       }
      }
        }    
 }
    menucontent+="</table>"
 if (document.all) {
  menu.innerHTML=menucontent
 }
 if (document.layers) {
  document.menu.document.write(menucontent)
  document.menu.document.close()
 }
}

function dblclick() {
 if (document.all && showmenu==1) {
  document.all.menu.style.visibility="visible"
  document.all.menu.style.posLeft=x
  document.all.menu.style.posTop=y
 }
 if (document.layers && showmenu==1) {
  document.menu.visibility="visible"
  document.menu.left=x
  document.menu.top=y
 }
 if (document.all && showmenu!=1) {
  document.all.menu.style.visibility="hidden"
 }
 if (document.layers && showmenu!=1) {
  document.menu.visibility="hidden"
 }
 showmenu=showmenu*-1
}


if (document.layers) {
document.captureEvents(Event.ONDBLCLICK);
}
document.ondblclick=dblclick;

if (document.layers){
 document.captureEvents(Event.MOUSEMOVE);
}
document.onmousemove = handlerMM;

function handlerMM(e){
 x = (document.layers) ? e.pageX : event.clientX
 y = (document.layers) ? e.pageY : event.clientY
}
// - End of JavaScript - -->

0

137

Выпадающее многоуровневое меню

Код:
<script language="javascript" src="menu-v4.js"></script>
<link rel=stylesheet href="v4.css" type="text/css">
<script language="javascript" src="sample-v4.js"></script>
</head>
<body bgcolor="000000" text="#00ff99" link="#00ff00" alink="#99ff00" vlink="#00cc00" onload="buildMenu('theMenu')">
<table cellpadding=0 cellspacing=0 border=0>
<tr align=top>
<td><a href="javascript:openMenu(0)" onMouseOver="overMenu(0); window.status=window.defaultStatus; return true;" onMouseOut="outMenu()">Меню 1</a> <div id="menu1"> </div></td>
<td><a href="javascript:openMenu(1)" onMouseOver="overMenu(1); window.status=window.defaultStatus; return true;" onMouseOut="outMenu()">Меню 2</a> <div id="menu2"> </div></td>
</tr>
</table>

Сохраните этот текст как файл с именем menu-v4 и расширением js, в ту же директорию, что и файлы, содержащие данное меню.

Код:
// Script begins

var isIE4 = false;
var isNN4 = false;

var flagMenu = "M";
var flagLink = "L";
var flagCommand = "C";
var flagSeparator = "S";

var charWidth = 7; // character width
var charHeight = 18; // character height
var colorNormal = "#009900"; // menu pad color
var colorHighlighted = "#006600"; // menu highlighted item color
var colorTopLine = "#ffff00"; // separator upper line color
var colorBottomLine = "#ffffff"; // separator lower line color

var borderSize = 1;
var marginSize = 4;
var marginString = "  ";
var subMenuFlagSize = 4;

var menuItemCount = -1;
var menuItem = new Array();
var menuFolderCount = -1;
var menuFolder = new Array();
var menuFolderSwitch = new Array();
var menuWidth = new Array();
var itemLayer = new Array();
var menuLayer = new Array();
var menuDone = new Array();

var itemOn = false;
var nnWidth = 0, nnHeight = 0;

function launchCommand(commandString) {
  // eval(commandString);
  alert(commandString);
}

function launchPage(pageURL) {
  document.location.assign(pageURL);
  //alert(pageURL);
}

function clickMenu(itemIndex) {
  var menuIndex = menuItem[itemIndex].myFolder;
  var folderIndex = menuItem[itemIndex].folder;
  var itemX = menuItem[itemIndex].x;
  var itemY = menuItem[itemIndex].y;

  if (menuItem[itemIndex].type == flagMenu) {
    if (menuFolderSwitch[folderIndex])
      hideMenu(folderIndex)
    else
      showMenu(folderIndex,itemX + menuWidth[menuIndex] * charWidth + subMenuFlagSize,itemY);
  }
  else if (menuItem[itemIndex].type == flagLink) {
    hideSubMenu();
    launchPage(menuItem[itemIndex].url);
  }
  else if (menuItem[itemIndex].type == flagCommand) {
    hideSubMenu();
    launchCommand(menuItem[itemIndex].command);
  }
}

function mouseOver() {
  var itemIndex = this.itemIndex;
  var menuIndex = menuItem[itemIndex].myFolder;
  var menuLength = menuFolder[menuIndex].length;
  var folderIndex = menuItem[itemIndex].folder;
  var itemX = menuItem[itemIndex].x;
  var itemY = menuItem[itemIndex].y;
  var thisFolder = 0;
  var thisItem = 0;

  itemOn = true;

  if (menuItem[itemIndex].type != flagSeparator) {
    if (isIE4) {
      this.style.backgroundColor = colorHighlighted;
    }
    else if (isNN4) {
      this.document.bgColor = colorHighlighted;
    }
  }

  for (var i = 0; i < menuLength; i++) {
    thisItem = menuFolder[menuIndex][i];

    if (thisItem != itemIndex)
      if (menuItem[thisItem].type == flagMenu) {
        thisFolder = menuItem[thisItem].folder;

        if (menuFolderSwitch[thisFolder])
          hideMenu(thisFolder);
      }
  }

  if (menuItem[itemIndex].type == flagMenu)
    if (!menuFolderSwitch[folderIndex])
      showMenu(folderIndex,itemX + menuWidth[menuIndex] * charWidth + subMenuFlagSize,itemY);

  window.status = menuItem[itemIndex].description;
  return true;
}

function mouseOut() {
  itemOn = false;

  if (isIE4)
    this.style.backgroundColor = colorNormal
  else if (isNN4)
    this.document.bgColor = colorNormal;

  window.status = "";
}

function menuItemUnit() {
  this.type = "";
  this.name = "";
  this.description = "";
  this.url = "";
  this.command = "";
  this.menu = "";
  this.folder = -1;
  this.myFolder = -1;
  this.x = -1;
  this.y = -1;
}

function readMenu(menuName) {
  var menu = eval(menuName);
  var menuLength = menu.length
  var thisFolder = ++menuFolderCount;

  menuFolder[thisFolder] = new Array();
  menuFolderSwitch[thisFolder] = false;
  menuWidth[thisFolder] = 0;
  menuLayer[thisFolder] = false;
  menuDone[thisFolder] = false;

  for (var i = 0; i < menuLength; i++) {
    menuFolder[thisFolder][i] = ++menuItemCount;
    itemLayer[menuItemCount] = false;

    menuItem[menuItemCount] = new menuItemUnit();
    menuItem[menuItemCount].myFolder = thisFolder;
    menuItem[menuItemCount].type = menu[i][0];
    menuItem[menuItemCount].name = menu[i][1];
    menuItem[menuItemCount].description = menu[i][2];

    if (menuWidth[thisFolder] < (menuItem[menuItemCount].name.length + marginSize))
      menuWidth[thisFolder] = menuItem[menuItemCount].name.length + marginSize;

    if (menuItem[menuItemCount].type == flagMenu) {
      menuItem[menuItemCount].menu = menu[i][3];
      menuItem[menuItemCount].folder = menuFolderCount + 1;
      readMenu(menuItem[menuItemCount].menu);
    }
    else if (menuItem[menuItemCount].type == flagLink) {
      menuItem[menuItemCount].url = menu[i][3];
    }
    else if (menuItem[menuItemCount].type == flagCommand) {
      menuItem[menuItemCount].command = menu[i][3];
    }
    else if (menuItem[menuItemCount].type != flagSeparator) {
      alert("Menu Error");
    }
  }
}

function getItem(itemIndex,itemDimX,itemDimY,menuIndex) {
  var thisItem = null;
  var subMenuFlag = (menuItem[itemIndex].type == flagMenu)?"subMenu.gif":"onePixel.gif";
  var singleQuote = "'";
  var itemID = "item" + itemIndex + "";
  var layerString = '<div id="' + itemID + '" style="position:absolute; width:' + itemDimX + '; background-color:' + colorNormal + '; visibility:hidden;"></div>';
  var htmlString = (menuItem[itemIndex].type == flagSeparator)?('<table width=' + itemDimX +' height=2 cellpadding=0 cellspacing=0 border=0><tr align=left valign=bottom><td bgcolor=' + colorTopLine + '><img src="onePixel.gif" width=1 height=1 border=0></td></tr><tr align=left valign=top><td bgcolor=' + colorBottomLine + '><img src="onePixel.gif" width=1 height=1 border=0></td></tr></table>'):('<table width=' + itemDimX +' height=' + itemDimY + ' cellpadding=0 cellspacing=0 border=0><tr align=left valign=middle><td nowrap><span id="menuText"><a class="menu" href="javascript:clickMenu(' + itemIndex + ')" onMouseOver="window.status=' + singleQuote + menuItem[itemIndex].description + singleQuote + ';return true;">' + marginString + menuItem[itemIndex].name + marginString + '</a></span></td><td><img src="' + subMenuFlag + '" width=4 height=7 border=0 align=right></td></tr></table>');

  if (!itemLayer[itemIndex]) {
    itemLayer[itemIndex] = true;

    if (isIE4) {
      document.body.insertAdjacentHTML("BeforeEnd",layerString);
      thisItem = document.all[itemID];

      thisItem.innerHTML = htmlString;
      thisItem.style.zIndex = menuIndex * 2 + 1;

      thisItem.onmouseover = mouseOver;
      if (menuItem[itemIndex].type != flagSeparator)
        thisItem.onmouseout = mouseOut;

      thisItem.itemIndex = itemIndex;
    }
    else if (isNN4) {
      document.layers[itemID] = new Layer(itemDimX);
      thisItem = document.layers[itemID];

      thisItem.visibility = "hidden";
      thisItem.document.open();
      thisItem.document.writeln(htmlString);
      thisItem.document.close();
      thisItem.document.bgColor = colorNormal;
      thisItem.zIndex = menuIndex * 2 + 1;

      thisItem.onmouseover = mouseOver;
      if (menuItem[itemIndex].type != flagSeparator)
        thisItem.onmouseout = mouseOut;

      thisItem.itemIndex = itemIndex;
    }
  }

  return itemID;
}

function getMenu(menuIndex,menuDimX,menuDimY) {
  var menuID = "menu" + menuIndex + "";
  var menuPadX = menuDimX + borderSize * 2;
  var menuPadY = menuDimY + borderSize * 2;
  var layerString = '<div id="' + menuID + '" style="position:absolute; width:' + menuPadX + '; visibility:hidden;"></div>';
  var htmlString = '<table width=' + menuPadX +' height=' + menuPadY + ' cellpadding=0 cellspacing=0 border=' + borderSize + '><tr align=left valign=middle><td></td></tr></table>';

  if (!menuLayer[menuIndex]) {
    menuLayer[menuIndex] = true;

    if (isIE4) {
      document.body.insertAdjacentHTML("BeforeEnd",layerString);

      document.all[menuID].innerHTML = htmlString;
      document.all[menuID].style.zIndex = menuIndex * 2;
    }
    else if (isNN4) {
      document.layers[menuID] = new Layer(menuPadX);

      document.layers[menuID].visibility = "hidden";
      document.layers[menuID].zIndex = menuIndex * 2;
      document.layers[menuID].document.open();
      document.layers[menuID].document.writeln(htmlString);
      document.layers[menuID].document.close();
    }
  }

  return menuID;
}

function showLayer(layerID) {
  if (isIE4)
    document.all[layerID].style.visibility = "visible"
  else if (isNN4)
    document.layers[layerID].visibility = "show";
}

function hideLayer(layerID) {
  if (isIE4)
    document.all[layerID].style.visibility = "hidden"
  else if (isNN4)
    document.layers[layerID].visibility = "hidden";
}

function moveLayerTo(layerID,x,y) {
  if (isIE4) {
    document.all[layerID].style.pixelLeft = x;
    document.all[layerID].style.pixelTop = y;
  }
  else if (isNN4) {
    document.layers[layerID].left = x;
    document.layers[layerID].top = y;
  }
}

function hideMenu(menuIndex) {
  var menuLength = menuFolder[menuIndex].length;
  var menuID = getMenu(menuIndex,0,0);
  var itemID = "";
  var itemIndex = 0;

  for (var i = 0; i < menuLength; i++) {
    itemIndex = menuFolder[menuIndex][i];

    if (menuItem[itemIndex].type == flagMenu)
      if (menuFolderSwitch[menuItem[itemIndex].folder])
        hideMenu(menuItem[itemIndex].folder);

    itemID = getItem(itemIndex,0,0,0);
    hideLayer(itemID);
  }

  hideLayer(menuID);

  menuFolderSwitch[menuIndex] = false;
}

function hideSubMenu() {
  var menuLength = menuFolder[0].length;

  for (var i = 0; i < menuLength; i++) {
    itemIndex = menuFolder[0][i];

    if (menuItem[itemIndex].type == flagMenu) {
      if (menuFolderSwitch[menuItem[itemIndex].folder])
        hideMenu(menuItem[itemIndex].folder);
    }
  }
}

function showMenu(menuIndex,menuX,menuY) {
  var itemDimY = menuY;
  var menuLength = menuFolder[menuIndex].length;
  var menuDimX = menuWidth[menuIndex] * charWidth + subMenuFlagSize;
  var menuID = "";
  var itemID = "";
  var itemIndex = 0;

  if (!menuDone[menuIndex]) {
    for (var i = 0; i < menuLength; i++) {
      itemIndex = menuFolder[menuIndex][i];

      menuItem[itemIndex].x = menuX;
      menuItem[itemIndex].y = itemDimY;
      itemDimY +=  (menuItem[itemIndex].type != flagSeparator)?charHeight:2;

      itemID = getItem(itemIndex,menuDimX,charHeight,menuIndex);

      moveLayerTo(itemID,menuItem[itemIndex].x,menuItem[itemIndex].y);
    }

    menuID = getMenu(menuIndex,menuDimX,itemDimY-menuY);
    moveLayerTo(menuID,menuX-borderSize,menuY-borderSize);

    menuDone[menuIndex] = true;
  }

  for (var i = 0; i < menuLength; i++)
    showLayer(getItem(menuFolder[menuIndex][i],0,0,0));

  showLayer(getMenu(menuIndex,0,0));

  menuFolderSwitch[menuIndex] = true;
}

function buildMenu(menuName,x,y) {
  isIE4 = document.all;
  isNN4 = document.layers;

  if (isIE4 || isNN4) {
    if (isNN4) {
      nnWidth = window.innerWidth;
      nnHeight = window.innerHeight;
      window.onResize = reloadMenu;
    }

    readMenu(menuName);
    showMenu(0,x,y);
    captureClick();
  }
}

function switchMenu(e) {
  if (!itemOn)
    hideSubMenu();

  if (isNN4) {
    routeEvent(e);
  }

  return true;
}

function captureClick() {
  if (isIE4)
    document.onclick = switchMenu;
  else {
    document.onClick = switchMenu;
    document.captureEvents(Event.CLICK);
  }
}

function reloadMenu() {
  if (nnWidth != window.innerWidth || nnHeight != window.innerHeight)
    document.location.reload();
}

// Script ends

Это файл содержит текст ссылки, ее описание в строке статуса и саму ссылку. Сделав свой файл, сохраните его с именем sample-v4 и расширением js в той же директории. База может быть сгенерирована генератором баз данных для многоуровневых меню

Код:
var theMenu = new Array();
theMenu[0] = new Array("myMenu1","menu1");
theMenu[1] = new Array("myMenu2","menu2");

Сохраните этот текст как файл с именем v4 и расширением css, в ту же директорию, что и файлы, содержащие данное меню.

Код:
a.menu {text-decoration:none; 
color:#000000}
#menuText 
{font-size:12px; 
color:#000000; 
font-family:arial,verdana,courier,times;}
#menu1 {position:relative; 
left:0; 
top:0; 
visibility:visible; 
z-index:1;}
#menu2 {position:relative; 
left:0; 
top:0; 
visibility:visible; 
z-index:1;}

0

138

Выпадающее многоуровневое меню

Код:
<link rel="stylesheet" href="v6.css" type="text/css">
<script language="javascript" src="menu-v6.js"></script>
<script language="javascript" src="sample-v6.js"></script>
</head>
<body bgcolor="000000" text="#00ff99" link="#00ff00" alink="#99ff00" vlink="#00cc00" onload="buildMenu('theMenu')">
<p><div id="menuHolder"></div></p>

Сохраните этот текст, как файл с именем menu-v6 и расширением js, в ту же директорию что и файлы, содержащие данное меню.

Код:
// Script begins

var isIE4 = false;
var isNN4 = false;

var flagMenu = "M";
var flagLink = "L";
var flagCommand = "C";
var flagSeparator = "S";

var titleWidth = 9; // title character width
var titleHeight = 17; // title character height
var charWidth = 7; // item character width
var charHeight = 15; // item character height

var titleNormal = "#cccccc"; // menu title pad color
var titleHighlighted = "#006600"; // menu title pad highlighted color
var itemNormal = "#009900"; // menu item color
var itemHighlighted = "#006600"; // menu highlighted item color
var upperLine = "#999999"; // separator upper line color
var lowerLine = "#00ff00"; // separator lower line color

var borderSize = 1;
var marginSize = 4;
var marginString = "  ";
var subMenuFlagSize = 4;
var menuHolder = "menuHolder";

var menuOffsetX = new Array();
var menuOffsetY = borderSize * 2 + titleHeight;

var menuShown = -1;
var itemOn = false;
var nnWidth = 0, nnHeight = 0;

var menuItemCount = -1;
var menuItem = new Array();
var menuFolderCount = -1;
var menuFolder = new Array();
var menuFolderSwitch = new Array();
var menuWidth = new Array();
var itemLayer = new Array();
var menuLayer = new Array();
var menuDone = new Array();

function launchCommand(commandString) {
  eval(commandString);
}

function launchPage(pageURL) {
  document.location.assign(pageURL);
}

function clickMenu(menuNum,itemIndex) {
  var menuIndex = menuItem[menuNum][itemIndex].myFolder;
  var folderIndex = menuItem[menuNum][itemIndex].folder;
  var itemX = menuItem[menuNum][itemIndex].x;
  var itemY = menuItem[menuNum][itemIndex].y;

  if (menuItem[menuNum][itemIndex].type == flagMenu) {
    if (menuFolderSwitch[menuNum][folderIndex])
      hideMenu(menuNum,folderIndex)
    else
      showMenu(menuNum,folderIndex,itemX + menuWidth[menuNum][menuIndex] * charWidth + subMenuFlagSize,itemY);
  }
  else if (menuItem[menuNum][itemIndex].type == flagLink) {
    closeMenu(menuNum);
    launchPage(menuItem[menuNum][itemIndex].url);
  }
  else if (menuItem[menuNum][itemIndex].type == flagCommand) {
    closeMenu(menuNum);
    launchCommand(menuItem[menuNum][itemIndex].command);
  }
}

function titleOver() {
  itemOn = true;

  if (isIE4)
    this.style.backgroundColor = titleHighlighted
  else
    this.document.bgColor = titleHighlighted;
}

function titleOut() {
  itemOn = false;

  if (isIE4)
    this.style.backgroundColor = titleNormal
  else
    this.document.bgColor = titleNormal;
}

function mouseOver() {
  var menuNum = this.menuNum;
  var itemIndex = this.itemIndex;
  var menuIndex = menuItem[menuNum][itemIndex].myFolder;
  var menuLength = menuFolder[menuNum][menuIndex].length;
  var folderIndex = menuItem[menuNum][itemIndex].folder;
  var itemX = menuItem[menuNum][itemIndex].x;
  var itemY = menuItem[menuNum][itemIndex].y;
  var thisFolder = 0;
  var thisItem = 0;

  itemOn = true;

  if (menuItem[menuNum][itemIndex].type != flagSeparator) {
    if (isIE4) {
      this.style.backgroundColor = itemHighlighted;
    }
    else if (isNN4) {
      this.document.bgColor = itemHighlighted;
    }
  }

  for (var i = 0; i < menuLength; i++) {
    thisItem = menuFolder[menuNum][menuIndex][i];

    if (thisItem != itemIndex)
      if (menuItem[menuNum][thisItem].type == flagMenu) {
        thisFolder = menuItem[menuNum][thisItem].folder;

        if (menuFolderSwitch[menuNum][thisFolder])
          hideMenu(menuNum,thisFolder);
      }
  }

  if (menuItem[menuNum][itemIndex].type == flagMenu)
    if (!menuFolderSwitch[menuNum][folderIndex])
      showMenu(menuNum,folderIndex,itemX + menuWidth[menuNum][menuIndex] * charWidth + subMenuFlagSize,itemY);

  window.status = menuItem[menuNum][itemIndex].description;
  return true;
}

function mouseOut() {
  itemOn = false;

  if (isIE4)
    this.style.backgroundColor = itemNormal
  else if (isNN4)
    this.document.bgColor = itemNormal;

  window.status = "";
  return true;
}

function menuItemUnit() {
  this.type = "";
  this.name = "";
  this.description = "";
  this.url = "";
  this.command = "";
  this.menu = "";
  this.folder = -1;
  this.myFolder = -1;
  this.x = -1;
  this.y = -1;
}

function readMenu(menuNum,menuName) {
  var menu = eval(menuName);
  var menuLength = menu.length
  var thisFolder = ++menuFolderCount;

  menuFolder[menuNum][thisFolder] = new Array();
  menuFolderSwitch[menuNum][thisFolder] = false;
  menuWidth[menuNum][thisFolder] = 0;
  menuLayer[menuNum][thisFolder] = false;
  menuDone[menuNum][thisFolder] = false;

  for (var i = 0; i < menuLength; i++) {
    menuFolder[menuNum][thisFolder][i] = ++menuItemCount;
    itemLayer[menuNum][menuItemCount] = false;

    menuItem[menuNum][menuItemCount] = new menuItemUnit();
    menuItem[menuNum][menuItemCount].myFolder = thisFolder;
    menuItem[menuNum][menuItemCount].type = menu[i][0];
    menuItem[menuNum][menuItemCount].name = menu[i][1];
    menuItem[menuNum][menuItemCount].description = menu[i][2];

    if (menuWidth[menuNum][thisFolder] < (menuItem[menuNum][menuItemCount].name.length + marginSize))
      menuWidth[menuNum][thisFolder] = menuItem[menuNum][menuItemCount].name.length + marginSize;

    if (menuItem[menuNum][menuItemCount].type == flagMenu) {
      menuItem[menuNum][menuItemCount].menu = menu[i][3];
      menuItem[menuNum][menuItemCount].folder = menuFolderCount + 1;
      readMenu(menuNum,menuItem[menuNum][menuItemCount].menu);
    }
    else if (menuItem[menuNum][menuItemCount].type == flagLink) {
      menuItem[menuNum][menuItemCount].url = menu[i][3];
    }
    else if (menuItem[menuNum][menuItemCount].type == flagCommand) {
      menuItem[menuNum][menuItemCount].command = menu[i][3];
    }
    else if (menuItem[menuNum][menuItemCount].type != flagSeparator) {
      alert("Error found in " + menuName);
    }
  }
}

function getItem(menuNum,itemIndex,itemDimX,itemDimY,menuIndex) {
  var thisLayer = null;
  var subMenuFlag = (menuItem[menuNum][itemIndex].type == flagMenu)?"subMenu.gif":"onePixel.gif";
  var singleQuote = "'";
  var itemID = "m" + menuNum + "i" + itemIndex + "";
  var layerString = '<div id="' + itemID + '" style="position:absolute; width:' + itemDimX + '; background-color:' + itemNormal + '; visibility:hidden;"></div>';
  var htmlString = (menuItem[menuNum][itemIndex].type == flagSeparator)?('<table width=' + itemDimX +' height=2 cellpadding=0 cellspacing=0 border=0><tr align=left valign=bottom><td bgcolor=' + upperLine + '><img src="onePixel.gif" width=1 height=1 border=0></td></tr><tr align=left valign=top><td bgcolor=' + lowerLine + '><img src="onePixel.gif" width=1 height=1 border=0></td></tr></table>'):('<table width=' + itemDimX +' height=' + itemDimY + ' cellpadding=0 cellspacing=0 border=0><tr align=left valign=middle><td nowrap><span id="menuText"><a class="menu" href="javascript:clickMenu(' + menuNum + ',' + itemIndex + ')" onMouseOver="window.status=' + singleQuote + menuItem[menuNum][itemIndex].description + singleQuote + ';return true;">' + marginString + menuItem[menuNum][itemIndex].name + marginString + '</a></span></td><td><img src="' + subMenuFlag + '" width=4 height=7 border=0 align=right></td></tr></table>');

  if (!itemLayer[menuNum][itemIndex]) {
    itemLayer[menuNum][itemIndex] = true;

    if (isIE4) {
      document.all[menuHolder].insertAdjacentHTML("BeforeEnd",layerString);
      thisLayer = document.all[itemID];

      thisLayer.innerHTML = htmlString;
      thisLayer.style.zIndex = menuIndex * 2 + 1;

      thisLayer.onmouseover = mouseOver;
      if (menuItem[menuNum][itemIndex].type != flagSeparator)
        thisLayer.onmouseout = mouseOut;
    }
    else if (isNN4) {
      document.layers[itemID] = new Layer(itemDimX,document.layers[menuHolder]);
      thisLayer = document.layers[itemID];

      thisLayer.visibility = "hidden";
      thisLayer.document.open();
      thisLayer.document.writeln(htmlString);
      thisLayer.document.close();
      thisLayer.document.bgColor = itemNormal;
      thisLayer.zIndex = menuIndex * 2 + 1;

      thisLayer.onmouseover = mouseOver;
      if (menuItem[menuNum][itemIndex].type != flagSeparator)
        thisLayer.onmouseout = mouseOut;
    }

    thisLayer.itemIndex = itemIndex;
    thisLayer.menuNum = menuNum;
  }

  return itemID;
}

function getMenu(menuNum,menuIndex,menuDimX,menuDimY) {
  var menuID = "m" + menuNum + "f" + menuIndex + "";
  var menuPadX = 0;
  var menuPadY = 0;
  var layerString = "";
  var htmlString = "";

  if (!menuLayer[menuNum][menuIndex]) {
    menuLayer[menuNum][menuIndex] = true;

    menuPadX = menuDimX + borderSize * 2;
    menuPadY = menuDimY + borderSize * 2;
    layerString = '<div id="' + menuID + '" style="position:absolute; width:' + menuPadX + '; visibility:hidden;"></div>';
    htmlString = '<table width=' + menuPadX +' height=' + menuPadY + ' cellpadding=0 cellspacing=0 border=' + borderSize + '><tr align=left valign=middle><td></td></tr></table>';

    if (isIE4) {
      document.all[menuHolder].insertAdjacentHTML("BeforeEnd",layerString);

      document.all[menuID].innerHTML = htmlString;
      document.all[menuID].style.zIndex = menuIndex * 2;
    }
    else if (isNN4) {
      document.layers[menuID] = new Layer(menuPadX,document.layers[menuHolder]);

      document.layers[menuID].visibility = "hidden";
      document.layers[menuID].zIndex = menuIndex * 2;
      document.layers[menuID].document.open();
      document.layers[menuID].document.writeln(htmlString);
      document.layers[menuID].document.close();
    }
  }

  return menuID;
}

function showTitle(menuArray,menuMaxX,menuMaxY) {
  var menuCount = menuArray.length;
  var menuTitleID = "menuTitle";
  var menuTitleBGID = "menuTitleBG";
  var menuTitleX = 0;
  var menuTitleY = titleHeight;
  var menuTitleBGX = 0;
  var menuTitleBGY = menuTitleY + borderSize * 2;
  var itemLength = 0;
  var titleLength = 0;
  var divStringFG = "";
  var divStringBG = "";
  var htmlStringFG = "";
  var htmlStringBG = "";
  var thisLayer = null;

  htmlStringFG = ' cellpadding=0 cellspacing=0 border=0><tr align=center valign=millde>';
  for (var i = 0; i < menuCount; i++) {
    itemLength = 2 + menuArray[i][0].length;
    menuOffsetX[i] = titleLength * titleWidth;
    htmlStringFG += ('<td width=' + (itemLength * titleWidth) + ' height=' + menuTitleY + '><nobr><span id="titleText"> <a class="menuTitle" href="javascript:openMenu(' + i + ')" onMouseOver="overMenu(' + i + '); window.status=window.defaultStatus; return true;">' + menuArray[i][0] + '</a> </span></nobr></td>');
    titleLength += itemLength;
  }
  menuTitleX = titleLength * titleWidth;
  menuTitleBGX = menuTitleX + borderSize * 2;

  htmlStringFG = '<table width=' + menuTitleX + ' height=' + menuTitleY + htmlStringFG + '</tr></table>';

  divStringFG = '<div id="' + menuTitleID + '" style="position:absolute; width:' + menuTitleX + '; background-color:' + titleNormal + '; visibility:hidden; z-index:2;"></div>';
  divStringBG = '<div id="' + menuTitleBGID + '" style="position:absolute; width:' + menuTitleBGX + '; visibility:hidden; z-index:1;"></div>';

  htmlStringBG = '<table width=' + menuTitleBGX +' height=' + menuTitleBGY + ' cellpadding=0 cellspacing=0 border=' + borderSize + '><tr><td></td></tr></table>';

  if (isIE4) {
    document.all[menuHolder].insertAdjacentHTML("BeforeEnd",divStringBG);
    document.all[menuTitleBGID].innerHTML = htmlStringBG;

    document.all[menuHolder].insertAdjacentHTML("BeforeEnd",divStringFG);
    thisLayer = document.all[menuTitleID];
    thisLayer.innerHTML = htmlStringFG;
  }
  else if (isNN4) {
    menuMaxX += menuTitleBGX;
    menuMaxY += menuTitleBGY;
    setMenuSize(menuMaxX,menuMaxY);

    document.layers[menuTitleBGID] = new Layer(menuTitleBGX,document.layers[menuHolder]);
    thisLayer = document.layers[menuTitleBGID];

    thisLayer.visibility = "hidden";
    thisLayer.document.open();
    thisLayer.document.writeln(htmlStringBG);
    thisLayer.document.close();
    thisLayer.zIndex = 1;

    document.layers[menuTitleID] = new Layer(menuTitleX,document.layers[menuHolder]);
    thisLayer = document.layers[menuTitleID];

    thisLayer.visibility = "hidden";
    thisLayer.document.open();
    thisLayer.document.writeln(htmlStringFG);
    thisLayer.document.close();
    thisLayer.document.bgColor = titleNormal;
    thisLayer.zIndex = 2;
  }

  thisLayer.onmouseover = titleOver;
  thisLayer.onmouseout = titleOut;

  moveLayerTo(menuTitleBGID,0,0);
  moveLayerTo(menuTitleID,borderSize,borderSize);
  showLayer(menuTitleBGID);
  showLayer(menuTitleID);
}

function showLayer(layerID) {
  if (isIE4)
    document.all[layerID].style.visibility = "visible"
  else if (isNN4)
    document.layers[layerID].visibility = "show";
}

function hideLayer(layerID) {
  if (isIE4)
    document.all[layerID].style.visibility = "hidden"
  else if (isNN4)
    document.layers[layerID].visibility = "hidden";
}

function moveLayerTo(layerID,x,y) {
  if (isIE4) {
    document.all[layerID].style.pixelLeft = x;
    document.all[layerID].style.pixelTop = y;
  }
  else if (isNN4) {
    document.layers[layerID].left = x;
    document.layers[layerID].top = y;
  }
}

function hideMenu(menuNum,menuIndex) {
  var menuLength = menuFolder[menuNum][menuIndex].length;
  var menuID = getMenu(menuNum,menuIndex,0,0);
  var itemID = "";
  var itemIndex = 0;

  for (var i = 0; i < menuLength; i++) {
    itemIndex = menuFolder[menuNum][menuIndex][i];

    if (menuItem[menuNum][itemIndex].type == flagMenu)
      if (menuFolderSwitch[menuNum][menuItem[menuNum][itemIndex].folder])
        hideMenu(menuNum,menuItem[menuNum][itemIndex].folder);

    itemID = getItem(menuNum,itemIndex,0,0,0);
    hideLayer(itemID);
  }

  hideLayer(menuID);

  menuFolderSwitch[menuNum][menuIndex] = false;
}

function showMenu(menuNum,menuIndex,menuX,menuY) {
  var itemDimY = menuY;
  var menuLength = menuFolder[menuNum][menuIndex].length;
  var menuDimX = menuWidth[menuNum][menuIndex] * charWidth + subMenuFlagSize;
  var menuID = "";
  var itemID = "";
  var itemIndex = 0;

  if (menuShown != -1 && menuShown != menuNum)
    hideMenu(menuShown,0);

  menuShown = menuNum;

  if (!menuDone[menuNum][menuIndex]) {
    for (var i = 0; i < menuLength; i++) {
      itemIndex = menuFolder[menuNum][menuIndex][i];

      menuItem[menuNum][itemIndex].x = menuX;
      menuItem[menuNum][itemIndex].y = itemDimY;
      itemDimY +=  (menuItem[menuNum][itemIndex].type != flagSeparator)?charHeight:2;

      itemID = getItem(menuNum,itemIndex,menuDimX,charHeight,menuIndex);

      moveLayerTo(itemID,menuItem[menuNum][itemIndex].x,menuItem[menuNum][itemIndex].y);
    }

    menuID = getMenu(menuNum,menuIndex,menuDimX,itemDimY-menuY);
    moveLayerTo(menuID,menuX-borderSize,menuY-borderSize);

    menuDone[menuNum][menuIndex] = true;
  }

  for (var i = 0; i < menuLength; i++)
    showLayer(getItem(menuNum,menuFolder[menuNum][menuIndex][i],0,0,0));

  showLayer(getMenu(menuNum,menuIndex,0,0));

  menuFolderSwitch[menuNum][menuIndex] = true;
}

function getMenuSizeX(menuNum,menuIndex) {
  var menuLength = menuFolder[menuNum][menuIndex].length;
  var itemIndex = 0;
  var thisMenuDimX = menuWidth[menuNum][menuIndex] * charWidth + subMenuFlagSize;
  var menuDimX = thisMenuDimX;
  var subMenuDimX = 0;

  for (var i = 0; i < menuLength; i++) {
    itemIndex = menuFolder[menuNum][menuIndex][i];

    if (menuItem[menuNum][itemIndex].type == flagMenu) {
      subMenuDimX = getMenuSizeX(menuNum,menuItem[menuNum][itemIndex].folder);

      if (menuDimX < (thisMenuDimX + subMenuDimX))
        menuDimX = thisMenuDimX + subMenuDimX;
    }
  }

  return menuDimX;
}

function getMenuSizeY(menuNum,menuIndex) {
  var menuLength = menuFolder[menuNum][menuIndex].length;
  var itemIndex = 0;
  var menuDimY = 0;
  var subMenuDimY = 0;
  var maxSubMenuDimY = 0;

  for (var i = 0; i < menuLength; i++) {
    itemIndex = menuFolder[menuNum][menuIndex][i];

    if (menuItem[menuNum][itemIndex].type == flagMenu) {
      subMenuDimY = getMenuSizeY(menuNum,menuItem[menuNum][itemIndex].folder);

      if (maxSubMenuDimY < (menuDimY + subMenuDimY))
        maxSubMenuDimY = menuDimY + subMenuDimY;

      menuDimY += charHeight;
    }
    else if (menuItem[menuNum][itemIndex].type == flagSeparator)
      menuDimY += 2
    else
      menuDimY += charHeight;
  }

  if (menuDimY < maxSubMenuDimY)
    return maxSubMenuDimY
  else
    return menuDimY;
}

function setMenuSize(menuDimX,menuDimY) {
  document.layers[menuHolder].clip.width=menuDimX;
  document.layers[menuHolder].clip.height=menuDimY;
}

function buildMenu(menuArrayName) {
  isIE4 = document.all;
  isNN4 = document.layers;

  var menuArray = eval(menuArrayName);
  var menuCount = menuArray.length;
  var menuSizeX = 0;
  var menuSizeY = 0;
  var menuMaxX = 0;
  var menuMaxY = 0;

  if (isIE4 || isNN4) {
    for (var i = 0; i < menuCount; i++) {
      menuItemCount = -1;
      menuFolderCount = -1;

      menuItem[i] = new Array();
      menuFolder[i] = new Array();
      menuFolderSwitch[i] = new Array();
      menuWidth[i] = new Array();

      itemLayer[i] = new Array();
      menuLayer[i] = new Array();
      menuDone[i] = new Array();

      readMenu(i,menuArray[i][1]);

      if (isNN4) {
        menuSizeX = getMenuSizeX(i,0) + borderSize * 2;
        menuSizeY = getMenuSizeY(i,0) + borderSize * 2;

        if (menuMaxX < menuSizeX)
          menuMaxX = menuSizeX;
        if (menuMaxY < menuSizeY)
          menuMaxY = menuSizeY;
      }
    }

    if (isNN4) {
      nnWidth = window.innerWidth;
      nnHeight = window.innerHeight;
      window.onResize = reloadMenu;
    }

    showTitle(menuArray,menuMaxX,menuMaxY);
    captureClick();
  }
}

function switchMenu() {
  if (!itemOn)
    if (menuShown != -1)
      closeMenu(menuShown);

  return true;
}

function captureClick() {
  if (isIE4)
    document.onclick = switchMenu;
  else {
    document.onClick = switchMenu;
    document.captureEvents(Event.CLICK);
  }
}

function reloadMenu() {
  if (nnWidth != window.innerWidth || nnHeight != window.innerHeight)
    document.location.reload();
}

function overMenu(menuNum) {
  if (menuShown != -1 && menuShown != menuNum)
    openMenu(menuNum);
}

function openMenu(menuNum) {
  if (menuShown == menuNum)
    closeMenu(menuNum)
  else
    showMenu(menuNum,0,borderSize + menuOffsetX[menuNum],borderSize + menuOffsetY);
}

function closeMenu(menuNum) {
  menuShown = -1;
  hideMenu(menuNum,0);
}

// Script ends

Это файл содержит текст ссылки, ее описание в строке статуса и саму ссылку. Сделав свой файл, сохраните его с именем sample-v6 и расширением js в той же директории. База может быть сгенерирована генератором баз данных для многоуровневых меню

Код:
var theMenu = new Array();
theMenu[0] = new Array("menu","myMenu1");
theMenu[1] = new Array("MENU","myMenu2");

Сохраните этот текст как файл с именем v6 и расширением css, в ту же директорию что и файлы, содержащие данное меню.

Код:
a.menu {text-decoration:none; color:#000000}
a.menuTitle {text-decoration:none; color:#000000}
a.menuTitle:hover {text-decoration:none; color:#ffff00}
#titleText {font-size:14px; color:#000000; font-family:arial,verdana,courier,times;}
#menuText {font-size:12px; color:#000000; font-family:arial,verdana,courier,times;}
#menuHolder {position:relative; left:0; top:0; visibility:visible; z-index:1;}

0

139

Перемена ссылок (одна за другой на одном месте)

Код:
<body onload="start_news();window.defaultStatus='Библиотека JavaScript';">
<table height="19" width="50%">
<tbody>
<tr><td width="50%">
<div align="left" id="ickertape">
<div align="left" class="subtickertapefont" id="subtickertape"><strong>Initializing.......</strong></div></div>
<script language=JavaScript>
<!-- // скорость смены ссылок
var speed=1800
var news=new Array()
news[0]="<a href='window.htm' target=_black><b><font color=#00FF40 style='{text-decoration: none;cursor: crosshair}'><DIV STYLE='FONT-size:12 Pt'>Дополнительное окно</DIV></font></b></a>"
news[1]="<a href='infill.htm' target=_black><b><font color=#6600FF size=-1 style='{text-decoration: none;cursor: crosshair}'><DIV STYLE='FONT-size:12 pt'>Заполнение форм</DIV></font></b></a>"
news[2]="<a href='game.htm' target=_black><b><font color=#FF80C0 size=-1 style='{text-decoration: none;cursor: crosshair}'><DIV STYLE='FONT-size:12 pt'>Игры</DIV></font></b></a>"
news[3]="<a href='clock.htm' target=_black><b><font color=#FF0000 size=-1 style='{text-decoration: none;cursor: crosshair}'><DIV STYLE='FONT-size:12 pt'>Календари и часики</DIV></font></b></a>"
news[4]="<a href='picture.htm' target=_black><b><font color=#FF33FF size=-1 style='{text-decoration: none;cursor: crosshair}'><DIV STYLE='FONT-size:12 pt'>Картинки</DIV></font></b></a>"
news[5]="<a href='writ.htm' target=_black><b><font color=#996600 style='{text-decoration: none;cursor: crosshair}'><DIV STYLE='FONT-size:12 Pt'>Надписи</DIV></font></b></a>"
news[6]="<a href='background.htm' target=_black><b><font color=#6600FF size=-1 style='{text-decoration: none;cursor: crosshair}'><DIV STYLE='FONT-size:12 pt'>Оформление фона</DIV></font></b></a>"
news[7]="<a href='object.htm' target=_black><b><font color=#FF80C0 size=-1 style='{text-decoration: none;cursor: crosshair}'><DIV STYLE='FONT-size:12 pt'>Передвижение объекта</DIV></font></b></a>"
news[8]="<a href='ball.htm' target=_black><b><font color=#6633cc  size=-1 style='{text-decoration: none;cursor: crosshair}'><DIV STYLE='FONT-size:12 pt'>Передвижение мячика</DIV></font></b></a>"
news[9]="<a href='orbit.htm' target=_black><b><font color=#669900 size=-1 style='{text-decoration: none;cursor: crosshair}'><DIV STYLE='FONT-size:12 pt'>Передвижение по орбите</DIV></font></b></a>"
news[10]="<a href='term.htm' target=_black><b><font color=#0099FF style='{text-decoration: none;cursor: crosshair}'><DIV STYLE='FONT-size:12 Pt'>Передвижение слов</DIV></font></b></a>"
news[11]="<a href='useful.htm' target=_black><b><font color=#6600FF size=-1 style='{text-decoration: none;cursor: crosshair}'><DIV STYLE='FONT-size:12 pt'>Полезное для сайтов</DIV></font></b></a>"
news[12]="<a href='frame.htm' target=_black><b><font color=#FFCC00 size=-1 style='{text-decoration: none;cursor: crosshair}'><DIV STYLE='FONT-size:12 pt'>Полезное для сайтов с фреймами</DIV></font></b></a>"
news[13]="<a href='various.htm' target=_black><b><font color=#FF80C0 size=-1 style='{text-decoration: none;cursor: crosshair}'><DIV STYLE='FONT-size:12 pt'>Разные скрипты</DIV></font></b></a>"
i=0
if (document.all)
tickerobject=document.all.subtickertape.style
else
tickerobject=document.tickertape.document
function regenerate(){
window.location.reload()
}
function regenerate2(){
if (document.layers)
setTimeout("window.onresize=regenerate",450)
}
function update(){
BgFade(0xff,0xff,0xff, 0x00,0x00,0x00,10);
if (document.layers){
document.tickertape.document.subtickertape.document.write('<span class="subtickertapefont">'+news[i]+'</span>')
document.tickertape.document.subtickertape.document.close()
}
else 
document.all.subtickertape.innerHTML=news[i]
if (i<news.length-1)
i++
else
i=0
setTimeout("update()",speed)
}
function BgFade(red1, grn1, blu1, red2,
grn2, blu2, steps) {
sred = red1; sgrn = grn1; sblu = blu1; 
ered = red2; egrn = grn2; eblu = blu2; 
inc = steps; 
step = 0; 
RunFader();
}
function RunFader() {
var epct = step/inc; 
var spct = 1 - epct; 
if (document.layers)
tickerobject.bgColor =
Math.floor(sred * spct + ered *
epct)*256*256 +
Math.floor(sgrn * spct + egrn * epct)*256 +
Math.floor(sblu * spct + eblu * epct); 
else
tickerobject.greygroundColor=
Math.floor(sred * spct + ered *
epct)*256*256 +
Math.floor(sgrn * spct + egrn * epct)*256 +
Math.floor(sblu * spct + eblu * epct); 
if ( step < inc ) {
setTimeout('RunFader()',50); 
}
step++;
}
function start_news()
{
if (document.all||document.layers){
regenerate2();update()}
}
-->
</script>
</td></tr></tbody>
</body>

0

140

Приглашение зайти при наведении на ссылку

Код:
<script src="utilwordmarker.js"></script>
<a href="http://scriptic.narod.ru" onMouseOver="showmessage('Привет!','Verdana','ffff00')" onMouseOut="hidemessage()"> Scriptic.narod.ru</a>

utilwordmarker.js

Код:
var x,y
var timer
var i_fadestrength=5
var step=1
var maxfontsize=180
var fontsizefactor=maxfontsize/100
var content

function cursorposition(e){
 x=event.clientX+document.body.scrollLeft
 y=event.clientY+document.body.scrollTop
}

function showmessage(whatmessage, whatfont, whatcolor) {
 if (document.all) {
  content="<nobr><font color="+whatcolor+" face="+whatfont+">"+whatmessage+"</font><nobr>"
  ring.innerHTML=content
  resizemessage()
 }
}

function resizemessage() {
if (document.all) {
 ring.filters.alpha.opacity=Math.floor(100-i_fadestrength)
 if (i_fadestrength>=120) {i_fadestrength=0;step=1}
 document.all.ring.style.visibility="visible"
 document.all.ring.style.fontSize=i_fadestrength*fontsizefactor
 document.all.ring.style.posLeft=x-(Math.floor(i_fadestrength/1.3*fontsizefactor))
 document.all.ring.style.posTop=y-(Math.floor(i_fadestrength/1.4*fontsizefactor)) 
 step+=1.5
 i_fadestrength+=step
 timer=setTimeout("resizemessage()",50)
}
}

function hidemessage(e){
if (document.all) {
 clearTimeout(timer)
 document.all.ring.style.visibility="hidden"
 i_fadestrength=5
 step=1
}
}

if (document.all) {
 document.onmousemove=cursorposition;
}

if (document.all) {
 document.write("<DIV id='ring' style='position:absolute;font-family:Verdana;filter:alpha(opacity=0);'></DIV>")
 document.write("<DIV style='position:relative;'>")
}

0

141

Прокручивающиеся на разном фоне ссылки

Код:
<SCRIPT LANGUAGE="JavaScript">
<!-- 
// Your messages. Add as many as you like
var message=new Array()
message[0]="SCRIPTIC.NAROD.RU"
message[1]="ФОКУСЫ JAVASCRIPT ЗДЕСЬ КЛИКАЙ."
message[2]="КАЧАЙ НУЖНОЕ КЛИКАЙ ЗДЕСЬ."
// the URLs of your messages
var messageurl=new Array()
messageurl[0]="http://scriptic.narod.ru/index.htm"
messageurl[1]="http://scriptic.narod.ru/javascript.htm"
messageurl[2]="http://scriptic.narod.ru/map.htm"
// the targets of the links
// accepted values are '_blank' or '_top' or '_parent' or '_self'
// or the name of your target-window (for instance 'main')
var messagetarget=new Array()
messagetarget[0]="_blank"
messagetarget[1]="_blank"
messagetarget[2]="_blank"
// the images that create the magic effect of the letters.
// You can add an image for each message 
var messageimage=new Array()
messageimage[0]="bg77_1.jpg"
messageimage[1]="bg77_2.jpg"
messageimage[2]="bg77_3.jpg"
// font-color of messages (required for Netscape Navigator)
var messagecolor="blue"
// distance of the scroller to the left margin of the browser-window (pixels)
var scrollerleft=20
// distance of the scroller to the top margin of the browser-window (pixels)
var scrollertop=20
// speed 1: lower means faster
var pause=20
// speed 2: higher means faster
var step=4
// font-size
var fntsize=30
// font-family
var fntfamily="Arial"
// font-weight: 1 means bold, 0 means normal
var fntweight=1
// do not edit the variables below
var imgpreload=new Array()
for (i=0;i<=messageimage.length-1;i++) {
imgpreload[i]=new Image()
imgpreload[i].src=messageimage[i]
}
var scrollerwidth=368
var scrollerheight=60
var backgroundimagecontent
var clipleft,clipright,cliptop,clipbottom,clipleftbg, cliprightbg
var i_message=0
var timer
var textwidth
var textcontent=""
if (fntweight==1) {fntweight="700"}
else {fntweight="100"}
function init() {
gettextcontent()
if (document.all) {
backgroundimagecontent="<img src='"+messageimage[0]+"' width='"+scrollerwidth+"'>"
text.innerHTML=textcontent
textwidth=text.offsetWidth
backgroundimage.innerHTML=backgroundimagecontent
document.all.text.style.height=scrollerheight
document.all.text.style.posTop=scrollertop
document.all.text.style.filter="chroma(color="+messagecolor+")"
document.all.text.style.posLeft=scrollerleft+scrollerwidth
document.all.backgroundimage.style.posTop=scrollertop
document.all.backgroundimage.style.posLeft=scrollerleft
clipleft=0
clipright=0
cliptop=0
clipbottom=scrollerheight
clipleftbg=scrollerwidth
cliprightbg=scrollerwidth
document.all.text.style.clip="rect("+cliptop+" "+clipright+" "+clipbottom+" "+clipleft+")"
document.all.backgroundimage.style.clip="rect("+cliptop+" "+cliprightbg+" "+clipbottom+" "+clipleftbg+")"
scrolltext()
}
if (document.layers) {
document.textnetscape.document.write(textcontent)
document.textnetscape.document.close()
textwidth=document.textnetscape.document.width
document.textnetscape.top=scrollertop
document.textnetscape.left=scrollerleft+scrollerwidth
document.textnetscape.clip.left=0
document.textnetscape.clip.right=0
document.textnetscape.clip.top=0
document.textnetscape.clip.bottom=scrollerheight
scrolltext()
}
}
function scrolltext() {
if (document.all) {
if (document.all.text.style.posLeft>=scrollerleft-textwidth) {
document.all.text.style.posLeft-=step
clipright+=step
clipleftbg-=step
if (clipright>scrollerwidth) {
clipleft+=step
}
if (document.all.text.style.posLeft<scrollerleft-textwidth+scrollerwidth) {
cliprightbg-=step
}
document.all.text.style.clip ="rect("+cliptop+" "+clipright+" "+clipbottom+" "+clipleft+")"
document.all.backgroundimage.style.clip="rect("+cliptop+" "+cliprightbg+" "+clipbottom+" "+clipleftbg+")"
var timer=setTimeout("scrolltext()",pause)
}
else {
changetext()
}
}
if (document.layers) {
if (document.textnetscape.left>=scrollerleft-textwidth) {
document.textnetscape.left-=step
document.textnetscape.clip.right+=step
if (document.textnetscape.clip.right>scrollerwidth) {
document.textnetscape.clip.left+=step
}
var timer=setTimeout("scrolltext()",pause)
}
else {
changetext()
}
}
}
function changetext() {
 i_message++
 if (i_message>message.length-1) {i_message=0}
 gettextcontent()
 if (document.all) {
text.innerHTML=textcontent
textwidth=text.offsetWidth
backgroundimagecontent="<img src='"+messageimage[i_message]+"' width='"+scrollerwidth+"'>"
backgroundimage.innerHTML=backgroundimagecontent
document.all.text.style.posLeft=scrollerleft+scrollerwidth
clipleft=0
clipright=0
clipleftbg=scrollerwidth
cliprightbg=scrollerwidth
document.all.text.style.clip="rect("+cliptop+" "+clipright+" "+clipbottom+" "+clipleft+")"
document.all.backgroundimage.style.clip="rect("+cliptop+" "+cliprightbg+" "+clipbottom+" "+clipleftbg+")"
scrolltext()
}
if (document.layers) {
document.textnetscape.document.write(textcontent)
document.textnetscape.document.close()
textwidth=document.textnetscape.document.width
document.textnetscape.left=scrollerleft+scrollerwidth
document.textnetscape.clip.left=0
document.textnetscape.clip.right=0 
scrolltext()
}
}
function gettextcontent() {
textcontent="<span style='position:relative;font-size:"+fntsize+"pt;font-family:"+fntfamily+";font-weight:"+fntweight+"'>"
textcontent+="<a href="+messageurl[i_message]+" target="+messagetarget[i_message]+">"
textcontent+="<nobr><font color="+messagecolor+">"+message[i_message]+"</font></nobr></a></span>"
}
window.onresize=init;
// - End of JavaScript - -->
</SCRIPT>
 </HEAD> 
<body bgcolor="#000000" text="#00ccff" link="#33ffff" alink="#99ffff" vlink="#0099ff" onLoad="init()"> 
<iframe src="menu.htm" align="left" width="140" height="560" scrolling="no" frameborder="0"></iframe>
<DIV ID="backgroundimage" style="position:absolute;left:-2000px;"></DIV>
<DIV ID="text" style="position:absolute;left:-2000px; background-color:Black;filter:chroma(color=black;);"></DIV>
<DIV ID="textnetscape" style="position:absolute;left:-2000px;"></DIV>

0

142

Прокручивающиеся ссылки

Код:
<SCRIPT LANGUAGE="JavaScript">
<!-- 
// Your messages. Add as many as you like
var message=new Array()
message[0]="SCRIPTIC.NAROD.RU: CLICK HERE."
message[1]="ФОКУСЫ JAVASCRIPT КЛИКАЙ ЗДЕСЬ."
message[2]="КАЧАЙ НУЖНОЕ КЛИКАЙ ЗДЕСЬ."
// the URLs of your messages
var messageurl=new Array()
messageurl[0]="http://SCRIPTIC.NAROD.RU"
messageurl[1]="http://SCRIPTIC.NAROD.RU"
messageurl[2]="http://SCRIPTIC.NAROD.RU"
// the targets of the links
// accepted values are '_blank' or '_top' or '_parent' or '_self'
// or the name of your target-window (for instance 'main')
var messagetarget=new Array()
messagetarget[0]="_blank"
messagetarget[1]="_blank"
messagetarget[2]="_blank"
// font-color
var messagecolor= new Array()
messagecolor[0]="red"
messagecolor[1]="blue"
messagecolor[2]="Yellow"
// distance of the scroller to the left margin of the browser-window (pixels)
var scrollerleft=20
// distance of the scroller to the top margin of the browser-window (pixels)
var scrollertop=20
// width of the scroller (pixels)
var scrollerwidth=300
// height of the scroller (pixels)
var scrollerheight=20
// speed 1: lower means faster
var pause=20
// speed 2: higher means faster
var step=2
// font-size
var fntsize=10
// font-family
var fntfamily="Arial"
// font-weight: 1 means bold, 0 means normal
var fntweight=1
// do not edit the variables below
var fadeimgwidth=60
var fadeimgleftcontent,fadeimgrightcontent
var clipleft,clipright,cliptop,clipbottom
var i_message=0
var timer
var textwidth
var textcontent=""
if (fntweight==1) {fntweight="700"}
else {fntweight="100"}
function init() {
gettextcontent()
fadeimgleftcontent="<img src='images/fadeimgleft.gif' width="+fadeimgwidth+" height="+scrollerheight+">"
fadeimgrightcontent="<img src='images/fadeimgright.gif' width="+fadeimgwidth+" height="+scrollerheight+">"
if (document.all) {
text.innerHTML=textcontent
fadeimgleft.innerHTML=fadeimgleftcontent
fadeimgright.innerHTML=fadeimgrightcontent
textwidth=text.offsetWidth
document.all.text.style.posTop=scrollertop
document.all.text.style.posLeft=scrollerleft+scrollerwidth
document.all.fadeimgleft.style.posTop=scrollertop
document.all.fadeimgleft.style.posLeft=scrollerleft
document.all.fadeimgright.style.posTop=scrollertop
document.all.fadeimgright.style.posLeft=scrollerleft+scrollerwidth-fadeimgwidth
clipleft=0
clipright=0
cliptop=0
clipbottom=scrollerheight
document.all.text.style.clip ="rect("+cliptop+" "+clipright+" "+clipbottom+" "+clipleft+")"
scrolltext()
}
if (document.layers) {
document.text.document.write(textcontent)
document.text.document.close()
document.fadeimgleft.document.write(fadeimgleftcontent)
document.fadeimgleft.document.close()
document.fadeimgright.document.write(fadeimgrightcontent)
document.fadeimgright.document.close()
textwidth=document.text.document.width
document.text.top=scrollertop
document.text.left=scrollerleft+scrollerwidth
document.fadeimgleft.top=scrollertop
document.fadeimgleft.left=scrollerleft
document.fadeimgright.top=scrollertop
document.fadeimgright.left=scrollerleft+scrollerwidth-fadeimgwidth
document.text.clip.left=0
document.text.clip.right=0
document.text.clip.top=0
document.text.clip.bottom=scrollerheight
scrolltext()
}
}
function scrolltext() {
if (document.all) {
if (document.all.text.style.posLeft>=scrollerleft-textwidth) {
document.all.text.style.posLeft-=step
clipright+=step
if (clipright>scrollerwidth) {
clipleft+=step
}
document.all.text.style.clip ="rect("+cliptop+" "+clipright+" "+clipbottom+" "+clipleft+")"
var timer=setTimeout("scrolltext()",pause)
}
else {
changetext()
}
}
if (document.layers) {
if (document.text.left>=scrollerleft-textwidth) {
document.text.left-=step
document.text.clip.right+=step
if (document.text.clip.right>scrollerwidth) {
document.text.clip.left+=step
}
var timer=setTimeout("scrolltext()",pause)
}
else {
changetext()
}
}
}
function changetext() {
i_message++
if (i_message>message.length-1) {i_message=0}
gettextcontent()
if (document.all) {
text.innerHTML=textcontent
textwidth=text.offsetWidth
document.all.text.style.posLeft=scrollerleft+scrollerwidth
clipleft=0
clipright=0
document.all.text.style.clip ="rect("+cliptop+" "+clipright+" "+clipbottom+" "+clipleft+")"
scrolltext()
 }
if (document.layers) {
document.text.document.write(textcontent)
document.text.document.close()
textwidth=document.text.document.width
document.text.left=scrollerleft+scrollerwidth
document.text.clip.left=0
document.text.clip.right=0
scrolltext()
}
}
function gettextcontent() {
textcontent="<span style='position:relative;font-size:"+fntsize+"pt;font-family:"+fntfamily+";font-weight:"+fntweight+"'>"
textcontent+="<a href="+messageurl[i_message]+" target="+messagetarget[i_message]+">"
textcontent+="<nobr><font color="+messagecolor[i_message]+">"+message[i_message]+"</font></nobr></a></span>"
}
window.onresize=init;
// - End of JavaScript - -->
</SCRIPT>
 </HEAD> 
<body onLoad="init()"> 
<DIV ID="text" style="position:absolute;left:-2000px"></DIV>
<DIV ID="fadeimgleft" style="position:absolute;left:-2000px"><img src="fadeimgleft.gif"></DIV>
<DIV ID="fadeimgright" style="position:absolute;left:-2000px"><img src="fadeimgright.gif"></DIV>

0

143

Салют при наведении на ссылку

Код:
<script>
<!-- 
var debrisnumber=40
var debriscolor=new Array()
debriscolor[0]="FFAAAA"
debriscolor[1]="AA0000"
debriscolor[2]="770000"
debriscolor[3]="AA4444"
debriscolor[4]="EE4422"
var x_debrispos
var y_debrispos
var x,y
var x_random=new Array()
var y_random=new Array()
var max_explsteps=20
var i_explsteps=0
var i_color=0
var pause=10

function checkbrowser() {
    i_explsteps=0
    x_debrispos=x
    y_debrispos=y
    for (i=0;i<=debrisnumber;i++) {
        x_random[i]=Math.ceil(40*Math.random())-20
        y_random[i]=Math.ceil(40*Math.random())-20
 }
 if (document.all) {
        for (i=0;i<=debrisnumber;i++) {
            var thisspan=eval("document.all.span"+i+".style")
            thisspan.visibility="VISIBLE"
   thisspan.posLeft=x_debrispos
   thisspan.posTop=y_debrispos
  }
        explode_IE()
    }
    if (document.layers) {
        for (i=0;i<=debrisnumber;i++) {
            var thisspan=eval("document.span"+i)
            thisspan.visibility="VISIBLE"
            thisspan.left=x_debrispos
            thisspan.top=y_debrispos
  }
        explode_NN()
    }
}

function explode_IE() {
 if (i_explsteps<=max_explsteps) {
  for (i=0;i<=debrisnumber;i++) {
            var thisspan=eval("document.all.span"+i+".style")
            thisspan.posLeft+=x_random[i]
            thisspan.posTop+=y_random[i]
  }
  i_explsteps++
  var timer=setTimeout("explode_IE()",pause)
 }
 else {
  for (i=0;i<=debrisnumber;i++) {
         var thisspan=eval("document.all.span"+i+".style")
         thisspan.visibility="HIDDEN"
  }
  clearTimeout(timer)
 }
}
function explode_NN() {
 if (i_explsteps<=max_explsteps) {
  for (i=0;i<=debrisnumber;i++) {
            var thisspan=eval("document.span"+i)
            thisspan.left+=x_random[i]
            thisspan.top+=y_random[i]
  }
  i_explsteps++
  var timer=setTimeout("explode_NN()",pause)
 }
 else {
  for (i=0;i<=debrisnumber;i++) {
            var thisspan=eval("document.span"+i)
            thisspan.visibility="HIDDEN"
  }
  clearTimeout(timer)
 }
}
function handlerMM(e){
 x = (document.layers) ? e.pageX : document.body.scrollLeft+event.clientX
 y = (document.layers) ? e.pageY : document.body.scrollTop+event.clientY
}
if (document.layers){
 document.captureEvents(Event.MOUSEMOVE);
}
document.onmousemove = handlerMM;
// - End of JavaScript - -->
</script>
<style>
.spanstyle { position:absolute; visibility:hidden;}
</style>
</head>
<body bgcolor="000000" text="#00ff99" link="#00ff00" alink="#99ff00" vlink="#00cc00">
<iframe src="../menu.htm" align="left" width="140" height="560" scrolling="no" frameborder="0"></iframe>
<script>
<!-- Beginning of JavaScript -
for (i=0;i<=debrisnumber;i++) {
    document.write("<div id='span"+i+"' class='spanstyle'>")
    document.write("<table cellpadding=0 cellspacing=0>")
    document.write("<tr><td bgcolor="+debriscolor[i_color]+">")
    document.write("<img src='emptypixel236.gif' width=3>")
    document.write("</td></tr></table>")
    document.write("</div>")
    i_color++
    if (i_color>=debriscolor.length) {i_color=0}
}
// - End of JavaScript - -->
</script>
<DIV id="redir" style="position:absolute;top:10px;left:5px;visibility:visible">
<table width=580 ><tr><td align=center><font size="1" face="Verdana"><a href="http://scriptic.narod.ru" onMouseOver="checkbrowser()" target="_blank">Подведите мышь к ссылке</a> 
</td></tr></table>
</DIV>

0

144

эффект зеркала

Код:
<center>
<img id="reflect" src="pic.jpg">       
<br>
<script language="JavaScript1.2">
function f1(){
setInterval("mdiv.filters.wave.phase+=10",100);
}

if (document.all){
document.write('<img id=mdiv src="'+document.all.reflect.src+'" style="filter:wave(strength=3,freq=3,phase=0,lightstrength=30) blur() flipv()">')
window.onload=f1
}

</script>

0

145

выезжающее слева меню

Код:
<style>
<!--
#slidemenubar, #slidemenubar2{ position:absolute; left:-155px; width:160px;top:170px; border:1.5px solid green; background-color:lightyellow;layer-background-color:lightyellow; font:bold 12px Verdana; line-height:20px;}
body {
	background-image: url(../../hgc101.jpg);
}
.style2 {
	color: #0000FF;
	font-size: x-large;
	font-style: italic;
	font-family: Verdana, Arial, Helvetica, sans-serif;
}
-->
</style>



<script language="JavaScript1.2">
/*
Sliding Menu Bar Script- 
By Dynamic Web Design (www.dynamic-design.com.ua)
For full source code, installation instructions,
100's more DHTML scripts, and Terms Of
Use, visit http://www.dynamic-design.com.ua/develop/
*/

if (document.all)
document.write('<div id="slidemenubar2" style="left:-150" onMouseover="pull()" onMouseout="draw()">')
</script>
<layer id="slidemenubar" onMouseover="pull()" onMouseout="draw()">
<script language="JavaScript1.2">
var sitems=new Array()
var sitemlinks=new Array()

//extend or shorten this list
sitems[0]="Главная страница"
sitems[1]="Скриптов"
sitems[2]="Учебник-HTML"



//These are the links pertaining to the above text.
sitemlinks[0]="http://site-help.narod.ru"
sitemlinks[1]="../../scripts.htm"
sitemlinks[2]="../../books.html"


for (i=0;i<=sitems.length-1;i++)
document.write('<a href='+sitemlinks[i]+'>'+sitems[i]+'</a><br>')
</script>
</layer>
<script language="JavaScript1.2">
function regenerate(){
window.location.reload()
}
function regenerate2(){
if (document.layers)
setTimeout("window.onresize=regenerate",400)
}
window.onload=regenerate2
if (document.all){
document.write('</div>')
themenu=document.all.slidemenubar2.style

rightboundary=0
leftboundary=-150
} else{
themenu=document.layers.slidemenubar
rightboundary=150
leftboundary=10
}

function pull(){
if (window.drawit)
clearInterval(drawit)
pullit=setInterval("pullengine()",50)
}

function draw(){
clearInterval(pullit)
drawit=setInterval("drawengine()",50)
}

function pullengine(){
if (document.all&&themenu.pixelLeft<rightboundary)
themenu.pixelLeft+=5
else if(document.layers&&themenu.left<rightboundary)
themenu.left+=5
else if (window.pullit)
clearInterval(pullit)
}

function drawengine(){
if (document.all&&themenu.pixelLeft>leftboundary)
themenu.pixelLeft-=5
else if(document.layers&&themenu.left>leftboundary)
themenu.left-=5
else if (window.drawit)
clearInterval(drawit)
}

</script>

0

146

время существования страницы

Код:
<script language="JavaScript">
d0 = new Date('May 6, 2005');
d1 = new Date();
dt = (d1.getTime() - d0.getTime()) / (1000*60*60*24);
document.write('Этой страничке <font color=#008000>' + Math.round(dt) + '-й</font> день.');
</script>

0

147

скрыть объявление

Код:
<script type="text/javascript">
    document.getElementById('pun-announcement').getElementsByTagName("div")[0].id="annbody"
    function lookCook()
    {
    if (document.cookie.indexOf("announce")!=-1)
    {var an1=document.cookie.substr(document.cookie.indexOf("announce"))
    var an=an1.substr(an1.indexOf("id")+2, 2)
    if (an=="op")
    {document.getElementById('annbody').style.display="block"
    var knopka="Скрыть объявление"}
    else if (an=="cl")
    {document.getElementById('annbody').style.display="none"
    var knopka="Показать объявление"}}
    else if (document.cookie.indexOf("announce")==-1)
    {document.getElementById('annbody').style.display="block"
    var knopka="Скрыть объявление"}
    document.getElementById('pun-announcement').getElementsByTagName("h2")[0].innerHTML+="<div align='right'>"+"<input type='button'"+" id='hider'"+" value='"+knopka+"' "+"onclick='hideAnn() ; wCook()' /></div>"}

    lookCook()

    function hideAnn()
    {
    if (document.getElementById('annbody').style.display!="none")
    {document.getElementById('annbody').style.display="none"
    document.getElementById('hider').value="Показать объявление"}
    else
    {document.getElementById('annbody').style.display="block"
    document.getElementById('hider').value="Скрыть объявление"}
    }

    function wCook()
    {
    var ann="announce=id"
    if (document.getElementById('annbody').style.display!="none")
    {ann+="op"}
    else
    {ann+="cl"}
    var d=new Date()
    d.setDate(d.getDate()+1)
    ann+=";expires="+d.toGMTString()
    document.cookie=ann}

    </script>

ставить непосредственно перед объявлением

0

148

Счётчик символов

Код:
<input id="num" type="text" class="codeButtons" readonly="true" style="width:40px;text-align:center" title="Счётчик символов">
<script type="text/javascript">
document.getElementById("main-reply").addEventListener('focus', nc, false);
document.getElementById("main-reply").addEventListener('keydown', nc, false);
document.getElementById("main-reply").addEventListener('keyup', nc, false);
document.getElementById("main-reply").addEventListener('keypress', nc, false);
document.getElementById("main-reply").addEventListener('change', nc, false);
function nc(){document.getElementById('num').value = document.getElementById('main-reply').value.length}    
</script>

вставлять в форму ответа

0

149

Окно предупреждения о новом ЛС

Код:
<script language="JavaScript">
var str = new String(document.getElementById("navpm").innerHTML)
var str2 = new String(document.location)
if( (str.indexOf("(") != -1) && (str2.indexOf("messages.php") == -1) )
{
alert("Вам телеграмма!")
}
</script>

0

150

Ныне популярное "облако тегов" - когда куча ссылок представляется в форме шарика, который можно покрутить. Вставляется куда попало.

Код:
<div id="yoblako"><noindex><a href="" rel="nofollow" class="eTag eTagGr14">Ссылка1</a><a href="" rel="nofollow" class="eTag eTagGr15">Ссылка2</a></noindex></div>

0


Вы здесь » Crossroads of Shinigami » Общее » Скрипты