Java Script'ы
Этот скрипт
выводит сообщение при попытке нажать правую кнопку мыши:
<script
language="JavaScript">
function click()
{
if (event.button==2)
{
alert('Эта операция запрещена!');
}
}
document.onmousedown=click
</script>
Этот скрипт
выводит информацию о том, сколько дней уже существует сайт:
<script
language="JavaScript">
d0 = new Date('May 2, 2000');
d1 = new Date();
dt = (d1.getTime() - d0.getTime()) / (1000*60*60*24);
document.write('Сайту Program Studio <font
color=#008000>' + Math.round(dt) + '-й</font> день.');
</script>
Меняем текст в StatusBar браузера
<script
language="javascript">
window.defaultStatus='Ваш текст'
</script>
Делаем страницу
стартовой.
<a href="#" onClick="this.style.behavior='url(#default#homepage)';
this.setHomePage('http://vbhtml.dax.ru/'); return false;">
Сделать страницу стартовой</a>
Добавляем
страницу в "избранное".
<a href="#" onClick="window.external.addFavorite
('http://vbhtml.dax.ru/', 'сайт'); return false;">
Добавить сайт в
избранное</a>
Дата последней
модификации.
<script language="JavaScript">
<!--
document.write
("Дата последнего изменения: "
+ document.lastModified);
//-->
</script>
Перемещение за
мышкой
<head>
<STYLE>
.spanstyle {position: absolute; top: -50px; visibility: visible}
</STYLE>
<SCRIPT>
var message="Д О Б Р О П О Ж А Л О В А Т Ь ! ! ! "
message=message.split(" ")
var step=8
var stepbasic=8
var x,y
var flag=0
var xpos=new Array()
for (i=0;i<=message.length-1;i++) {
xpos[i]=-100
}
var ypos=new Array()
for (i=0;i<=message.length-1;i++) {
ypos[i]=-100
}
var spacebetweenwords=new Array()
for (i=0;i<=message.length-1;i++) {
spacebetweenwords[i]=stepbasic+step*message[i].length-1
}
var colorstep=Math.round(255/message.length-1)
var colorrgb=new Array()
for (i=0;i<=message.length-1;i++) {
colorrgb[i]=i*colorstep
}
var wordcolor=new Array()
for (i=0;i<=message.length-1;i++) {
var colhex_left = Math.floor(colorrgb[i]/16)
var colhex_right= colorrgb[i]-(colhex_left*16)
if (colhex_left == 10) {colhex_left="A"}
if (colhex_left == 11) {colhex_left="B"}
if (colhex_left == 12) {colhex_left="C"}
if (colhex_left == 13) {colhex_left="D"}
if (colhex_left == 14) {colhex_left="E"}
if (colhex_left == 15) {colhex_left="F"}
if (colhex_right == 10) {colhex_right="A"}
if (colhex_right == 11) {colhex_right="B"}
if (colhex_right == 12) {colhex_right="C"}
if (colhex_right == 13) {colhex_right="D"}
if (colhex_right == 14) {colhex_right="E"}
if (colhex_right == 15) {colhex_right="F"}
wordcolor[i] =""+colhex_left+colhex_right
}
function handlerMM(e){
x = (document.layers) ? e.pageX : document.body.scrollLeft+event.clientX
y = (document.layers) ? e.pageY : document.body.scrollTop+event.clientY
flag=1
}
function makesnake() {
if (flag==1 && document.all) {
for (i=message.length-1; i>=1; i--) {
xpos[i]=xpos[i-1]+spacebetweenwords[i-1]
ypos[i]=ypos[i-1]
}
xpos[0]=x+stepbasic
ypos[0]=y
for (i=0; i<message.length-1; i++) {
var thisspan = eval("span"+(i)+".style")
thisspan.posLeft=xpos[i]
thisspan.posTop=ypos[i]
}
}
else if (flag==1 && document.layers) {
for (i=message.length-1; i>=1; i--) {
xpos[i]=xpos[i-1]+spacebetweenwords[i-1]
ypos[i]=ypos[i-1]
}
xpos[0]=x+stepbasic
ypos[0]=y
for (i=0; i<message.length-1; i++) {
var thisspan = eval("document.span"+i)
thisspan.left=xpos[i]
thisspan.top=ypos[i]
}
}
var timer=setTimeout("makesnake()",30)
}
</SCRIPT>
</head>
<body onload=makesnake()
style="OVERFLOW-X: hidden; OVERFLOW-Y: scroll; WIDTH: 100%">
<SCRIPT>
for (i=0;i<=message.length-1;i++) {
document.write("<span id='span"+i+"'
class='spanstyle'>")
document.write("<font
color='"+wordcolor[i]+wordcolor[i]+wordcolor[i]+"'>"+message[i]+"</font>")
document.write("</span>")
}
if (document.layers){
document.captureEvents(Event.MOUSEMOVE);
}
document.onmousemove = handlerMM;
</SCRIPT>
</body>
изменение фона
страницы
<BODY onLoad="setbackground();">
<script language="JavaScript">
<!-- Start of JavaScript code
function setbackground()
{
window.setTimeout( "setbackground()", 5000); // 5000 миллисекунд это 5 секунд
var index = Math.round(Math.random() * 9);
var ColorValue = "FFFFFF"; // цвет по умолчанию - white (белый) (index = 0)
if(index == 1)
ColorValue = "FFCCCC"; //peach
if(index == 2)
ColorValue = "CCAFFF"; //violet
if(index == 3)
ColorValue = "A6BEFF"; //lt blue
if(index == 4)
ColorValue = "99FFFF"; //cyan
if(index == 5)
ColorValue = "D5CCBB"; //tan
if(index == 6)
ColorValue = "99FF99"; //lt green
if(index == 7)
ColorValue = "FFFF99"; //lt yellow
if(index == 8)
ColorValue = "FFCC99"; //lt orange
if(index == 9)
ColorValue = "CCCCCC"; //lt grey
document.bgColor=ColorValue;
}
// -- End of JavaScript code -------------- -->
</script>
Форма часов
<script language="JavaScript">
fCol='0000ff';
//цвет цифр на циферблате.
sCol='FF0000'; //Цвет секундных стрелок.
mCol='444444'; //цвет
минутных стрелок.
hCol='444444'; //Цвет
часовых стрелок.
Ybase=30; //Высота часов.
Xbase=30; //Ширина часов.
H='...';
H=H.split('');
M='....';
M=M.split('');
S='.....';
S=S.split('');
NS4=(document.layers);
NS6=(document.getElementById&&!document.all);
IE4=(document.all);
Ypos=0;
Xpos=0;
dots=12;
if (NS6){
for (i=1; i < dots+1; i++){
document.write('<div id="n6Digits'+i+'" style="position:absolute;top:0px;left:0px;width:30px;height:30px;font-family:Arial;font-size:10px;color:#'+fCol+';text-align:center;padding-top:10px">'+i+'</div>');
}
for (i=0; i < M.length; i++){
document.write('<div id="Ny'+i+'" style="position:absolute;top:0px;left:0px;width:2px;height:2px;font-size:2px;background:#'+mCol+'"></div>');
}
for (i=0; i < H.length; i++){
document.write('<div id="Nz'+i+'" style="position:absolute;top:0px;left:0px;width:2px;height:2px;font-size:2px;background:#'+hCol+'"></div>');
}
for (i=0; i < S.length; i++){
document.write('<div id="Nx'+i+'" style="position:absolute;top:0px;left:0px;width:2px;height:2px;font-size:2px;background:#'+sCol+'"></div>');
}
}
if (NS4){
dgts='1 2 3 4 5 6 7 8 9 10 11 12';
dgts=dgts.split(' ')
for (i=0; i < dots; i++){
document.write('<layer name=nsDigits'+i+' top=0 left=0 height=30 width=30><center><font face=Arial size=1 color='+fCol+'>'+dgts[i]+'</font></center></layer>');
}
for (i=0; i < M.length; i++){
document.write('<layer name=ny'+i+' top=0 left=0 bgcolor='+mCol+' clip="0,0,2,2"></layer>');
}
for (i=0; i < H.length; i++){
document.write('<layer name=nz'+i+' top=0 left=0 bgcolor='+hCol+' clip="0,0,2,2"></layer>');
}
for (i=0; i < S.length; i++){
document.write('<layer name=nx'+i+' top=0 left=0 bgcolor='+sCol+' clip="0,0,2,2"></layer>');
}
}
if (IE4){
document.write('<div style="position:absolute;top:0px;left:0px"><div style="position:relative">');
for (i=1; i < dots+1; i++){
document.write('<div id="ieDigits" style="position:absolute;top:0px;left:0px;width:30px;height:30px;font-family:Arial;font-size:10px;color:'+fCol+';text-align:center;padding-top:10px">'+i+'</div>');
}
document.write('</div></div>')
document.write('<div style="position:absolute;top:0px;left:0px"><div style="position:relative">');
for (i=0; i < M.length; i++){
document.write('<div id=y style="position:absolute;width:2px;height:2px;font-size:2px;background:'+mCol+'"></div>');
}
document.write('</div></div>')
document.write('<div style="position:absolute;top:0px;left:0px"><div style="position:relative">');
for (i=0; i < H.length; i++){
document.write('<div id=z style="position:absolute;width:2px;height:2px;font-size:2px;background:'+hCol+'"></div>');
}
document.write('</div></div>')
document.write('<div style="position:absolute;top:0px;left:0px"><div style="position:relative">');
for (i=0; i < S.length; i++){
document.write('<div id=x style="position:absolute;width:2px;height:2px;font-size:2px;background:'+sCol+'"></div>');
}
document.write('</div></div>')
}
function clock(){
time = new Date ();
secs = time.getSeconds();
sec = -1.57 + Math.PI * secs/30;
mins = time.getMinutes();
min = -1.57 + Math.PI * mins/30;
hr = time.getHours();
hrs = -1.57 + Math.PI * hr/6 + Math.PI*parseInt(time.getMinutes())/360;
if (NS6){
Ypos=window.pageYOffset+window.innerHeight-Ybase-25;
Xpos=window.pageXOffset+window.innerWidth-Xbase-30;
for (i=1; i < dots+1; i++){
document.getElementById("n6Digits"+i).style.top=Ypos-15+Ybase*Math.sin(-1.56 +i *Split*Math.PI/180)
document.getElementById("n6Digits"+i).style.left=Xpos-15+Xbase*Math.cos(-1.56 +i*Split*Math.PI/180)
}
for (i=0; i < S.length; i++){
document.getElementById("Nx"+i).style.top=Ypos+i*Ybase/4.1*Math.sin(sec);
document.getElementById("Nx"+i).style.left=Xpos+i*Xbase/4.1*Math.cos(sec);
}
for (i=0; i < M.length; i++){
document.getElementById("Ny"+i).style.top=Ypos+i*Ybase/4.1*Math.sin(min);
document.getElementById("Ny"+i).style.left=Xpos+i*Xbase/4.1*Math.cos(min);
}
for (i=0; i < H.length; i++){
document.getElementById("Nz"+i).style.top=Ypos+i*Ybase/4.1*Math.sin(hrs);
document.getElementById("Nz"+i).style.left=Xpos+i*Xbase/4.1*Math.cos(hrs);
}
}
if (NS4){
Ypos=window.pageYOffset+window.innerHeight-Ybase-20;
Xpos=window.pageXOffset+window.innerWidth-Xbase-30;
for (i=0; i < dots; ++i){
document.layers["nsDigits"+i].top=Ypos-5+Ybase*Math.sin(-1.045 +i*Split*Math.PI/180)
document.layers["nsDigits"+i].left=Xpos-15+Xbase*Math.cos(-1.045 +i*Split*Math.PI/180)
}
for (i=0; i < S.length; i++){
document.layers["nx"+i].top=Ypos+i*Ybase/4.1*Math.sin(sec);
document.layers["nx"+i].left=Xpos+i*Xbase/4.1*Math.cos(sec);
}
for (i=0; i < M.length; i++){
document.layers["ny"+i].top=Ypos+i*Ybase/4.1*Math.sin(min);
document.layers["ny"+i].left=Xpos+i*Xbase/4.1*Math.cos(min);
}
for (i=0; i < H.length; i++){
document.layers["nz"+i].top=Ypos+i*Ybase/4.1*Math.sin(hrs);
document.layers["nz"+i].left=Xpos+i*Xbase/4.1*Math.cos(hrs);
}
}
if (IE4){
Ypos=document.body.scrollTop+window.document.body.clientHeight-Ybase-20;
Xpos=document.body.scrollLeft+window.document.body.clientWidth-Xbase-20;
for (i=0; i < dots; ++i){
ieDigits[i].style.pixelTop=Ypos-15+Ybase*Math.sin(-1.045 +i *Split*Math.PI/180)
ieDigits[i].style.pixelLeft=Xpos-15+Xbase*Math.cos(-1.045 +i *Split*Math.PI/180)
}
for (i=0; i < S.length; i++){
x[i].style.pixelTop =Ypos+i*Ybase/4.1*Math.sin(sec);
x[i].style.pixelLeft=Xpos+i*Xbase/4.1*Math.cos(sec);
}
for (i=0; i < M.length; i++){
y[i].style.pixelTop =Ypos+i*Ybase/4.1*Math.sin(min);
y[i].style.pixelLeft=Xpos+i*Xbase/4.1*Math.cos(min);
}
for (i=0; i < H.length; i++){
z[i].style.pixelTop =Ypos+i*Ybase/4.1*Math.sin(hrs);
z[i].style.pixelLeft=Xpos+i*Xbase/4.1*Math.cos(hrs);
}
}
setTimeout('clock()',100);
}
clock();
//-->
</script>
Приветствие посетителя
<H1>
<SCRIPT language=JavaScript><!--
// begin script
function display_title() {
var hours
= date.getHours();
var message = '';
if (hours >= 6) { time_of_day = 'Доброе утро';
message='Morning Message';}
if ((hours >= 12) && (hours <
17)) { time_of_day = 'Добрый день'; message='Afternoon Message'}
if (hours >= 17) { time_of_day = 'Добрый вечер'; message='Evening Message';}
if ((hours >= 0) && (hours <
6)){ time_of_day = 'Доброй ночи'; message='Night
Message';}
document.write('<CENTER><H1>Здравствуйте, ' +
time_of_day + '!</H1></CENTER><P>');
}
// document.write('<CENTER>' + message +
'<CENTER>');
//end
display title
function
display_date() {
date = new Date();
var day_of_week_number = date.getDay();
var day_of_month = date.getDate();
var month_number = date.getMonth();
var year = date.getYear();
var day_of_week = '';
var month = ''
if(month_number == 0){month = 'ЯНВАРЯ';}
if(month_number == 1){month = 'ФЕВРАЛЯ';}
if(month_number == 2){month = 'МАРТА';}
if(month_number == 3){month = 'АПРЕЛЯ';}
if(month_number == 4){month = 'МАЯ';}
if(month_number == 5){month = 'ИЮНЯ';}
if(month_number == 6){month = 'ИЮЛЯ';}
if(month_number == 7){month = 'АВГУСТА';}
if(month_number == 8){month = 'СЕНТЯБРЯ';}
if(month_number == 9){month = 'ОКТЯБРЯ';}
if(month_number == 10){month = 'НОЯБРЯ';}
if(month_number == 11){month ='ДЕКАБРЯ';}
if(day_of_week_number == 0){day_of_week = 'ВОСКРЕСЕНЬЕ';}
if(day_of_week_number == 1){day_of_week = 'ПОНЕДЕЛЬНИК';}
if(day_of_week_number == 2){day_of_week = 'ВТОРНИК';}
if(day_of_week_number == 3){day_of_week = 'СРЕДА';}
if(day_of_week_number == 4){day_of_week = 'ЧЕТВЕРГ';}
if(day_of_week_number == 5){day_of_week = 'ПЯТНИЦА';}
if(day_of_week_number == 6){day_of_week = 'СУББОТА';}
var date_to_show = day_of_week + ', ' + day_of_month + ' ' + month +
', ' + year + ' ГОДА.';
document.write('<CENTER><H4>' + date_to_show.fontcolor("#000000") + '</H4></CENTER>');
} //end
display date
//
--></SCRIPT>
</H1>
<H1><FONT color=#ff0000>
<SCRIPT
language=javascript><!-- begin script
display_date();
display_title();
//--></SCRIPT>
</FONT></H1>
Приветствие с
именем2
<script>
<!--
// Copyright (c) 1996-1997 Tomer Shiran. All rights reserved.
// Permission given to use the script provided that this notice remains as is.
// Additional scripts can be found at http://www.geocities.com/~yehuda/
// Boolean variable specified if alert should be displayed if cookie exceeds 4KB
var caution = false
// name - name of the cookie
// value - value of the cookie
// [expires] - expiration date of the cookie (defaults to end of current session)
// [path] - path for which the cookie is valid (defaults to path of calling document)
// [domain] - domain for which the cookie is valid (defaults to domain of calling document)
// [secure] - Boolean value indicating if the cookie transmission requires a secure transmission
// * an argument defaults when it is assigned null as a placeholder
// * a null placeholder is not required for trailing omitted arguments
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 exceeds 4KB and will be cut!"))
document.cookie = curCookie
}
// name - name of the desired cookie
// * return string containing value of specified cookie or null if cookie does not exist
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))
}
// name - name of the cookie
// [path] - path of the cookie (must be same as path used to create cookie)
// [domain] - domain of the cookie (must be same as domain used to create cookie)
// * path and domain default if assigned null or omitted if no explicit argument proceeds
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"
}
}
// date - any instance of the Date object
// * you should hand all instances of the Date object to this function for "repairs"
// * this function is taken from Chapter 14, "Time and Date in JavaScript", in "Learn Advanced JavaScript Programming"
function fixDate(date) {
var base = new Date(0)
var skew = base.getTime()
if (skew > 0)
date.setTime(date.getTime() - skew)
}
var now = new Date()
fixDate(now)
now.setTime(now.getTime() + 31 * 24 * 60 * 60 * 1000)
var name = getCookie("name")
if (!name)
name = prompt("Please enter your name:", "John Doe")
setCookie("name", name, now)
document.write("Hello " + name + "!")
//-->
</script>
Выпадающее меню
<form>
<input type="hidden" name="SB">
<SELECT NAME="Product" onchange="top.location.href = this.options[this.selectedIndex].value;">
<option selected value="#">Выпадающее меню</option>
<option VALUE="http://www.superbest.com/forum">Форум</option>
<option VALUE="http://www.superbest.com/links">Каталог ссылок</option>
<option VALUE="http://www.superbest.net/top">Рейтинг TOP-300</option>
</select>
</form>
звук на страницу
<SCRIPT>
function playHome() {
document.all.sound.src = "name.wav"}
</SCRIPT>
<BGSOUND id=sound>
звук на
страницу2
Если вы вставите этот
скрипт, то при каждой перезагрузке страницы на ней будет играть случайно
выбранная музыка.
Все что вам будет надо, это подготовить музыкальные файлы.
Возьмите свои любимые
музыкальные файлы в формате .midi и переименуйте их.
Например:
mid1.mid, mid2.mid, mid3.mid и так до mid9999.mid.
После этого загрузите их в
одну директорию со страничкой, в которую вставили этот скрипт, и при каждой
загрузке странички, будет играть новая музыка.
Если вы хотите чтобы музыка играла один раз, то оставьте параметр loop=false как в скрипте,
если хотите чтобы музыка повторялась по кругу, то измените этот параметр на loop=true
<script
language="JavaScript">
function
RandomNumber(i) {
num = Math.random();
today = new Date();
num = today.getTime();
num = (Math.round(Math.abs(Math.sin
(num)*1000000)) % 6)+1
return num;
}
function
Today() {
today = new Date()
month = (today.getMonth()+1)
day = today.getDate()
year = today.getYear()
return
day+"/"+month+"/"+year
}
function
SpecialSelect() {
if (Today() == "DD/M/YY")
return 1;
else if (Today() == "DD/M/YY")
return 2;
else if (Today() == "DD/M/YY")
return 3;
else return
0;
}
function
Select() {
number
= RandomNumber()
if (SpecialSelect() != 0)
return
"special"+SpecialSelect()+".mid";
else return
"mid"+number+".mid";
}
sound
= Select()
/*document.write("<BGSOUND
SRC=\"", sound, "\" LOOP=INFINITE>");*/
document.write("<center><embed
src=\"", sound, "\"
AUTOSTART=true loop=false VOLUME=35 WIDTH=140 HEIGHT=55
hidden=true></center>");
</script>
<body
bgcolor="#FFFFFF" onload="person_in()"
onunload="person_out()">
<script
language="JavaScript">
function
person_in() {
enter=new Date();
}
function
person_out() {
exit=new Date();
time_dif=(exit.getTime()-enter.getTime())/1000;
time_dif=Math.round(time_dif);
alert ("Вы были здесь:
" + time_dif + " секунд!")
}
</script>
Если вставить в страницу этот скрипт, страница при открытии будет выезжать из-за экрана.
Для настройки скрипта
используется следуюющая строчка:
WinScroll(4,800,600)
Первая цифра может быть от 1 до 4 и означает с какой стороны будет выезжать
страница.
1 - снизу
2 - сверху
3 - справа
4 - слева
Далее настраивается
размер выезжаемой страницы (в примере 800х600).
<HEAD>
<META HTTP-EQUIV="Page-Enter" content="revealTrans(Duration=0.5,Transition=3)">
<SCRIPT LANGUAGE="JavaScript">
<!--
function WinScroll(direction,xWidth,xHeight){
if ((navigator.appVersion.indexOf('4')!= -1)){
self.resizeTo(xWidth,xHeight)
if (direction == 1){ //Up
self.moveTo((screen.availWidth-xWidth)/2,screen.availHeight-10)
for (var c=1; c<=(screen.availHeight-(-xHeight))/2; c=c+4)
self.moveTo((screen.availWidth-xWidth)/2,screen.availHeight-c)
}
if (direction == 2){ //Down
var x=screen.availHeight+screen.Height
self.moveTo((screen.availWidth-xWidth)/2,(screen.availHeight-x))
for (var c=0; c<=(screen.availHeight-(-xHeight/2)); c=c+4)
self.moveTo((screen.availWidth-xWidth)/2,(screen.availHeight-x)+c)
}
if (direction == 3){ //left
var x=screen.availWidth-10
self.moveTo(x,(screen.availHeight-xHeight)/2)
for (var c=1; c<=(x-(-xWidth))/2; c=c+4)
self.moveTo((x-c),(screen.availHeight-xHeight)/2)
}
if (direction == 4){ //Right
var x=screen.availWidth+(xWidth-10)
self.moveTo((screen.availWidth-x),(screen.availHeight-xHeight)/2)
for (var c=1; c<=(screen.availWidth-(-xWidth))/2; c=c+4)
self.moveTo(((screen.availWidth-x)+c),(screen.availHeight-xHeight)/2)
}
}
}
WinScroll(4,800,600)
//-->
</SCRIPT>
</HEAD>
<head>
<style>
.spanstyle {
position:absolute;
visibility:visible;
top:-50px;
font-size:10pt;
font-family:Verdana;
font-weight:bold;
color:black;
}
</style>
</head>
<body onLoad="makesnake()" style="width:100%;overflow-x:hidden;overflow-y:scroll"
vlink="#0000FF"></body>
<script>
var x,y
var step=20
var flag=0
var message="SuperBest " // Текст около мышки (обязательно после
последней буквы пробел)
message=message.split("")
var xpos=new Array()
for (i=0;i<=message.length-1;i++) {
xpos[i]=-50
}
var ypos=new Array()
for (i=0;i<=message.length-1;i++) {
ypos[i]=-50
}
function handlerMM(e){
x = (document.layers) ? e.pageX : document.body.scrollLeft+event.clientX
y = (document.layers) ? e.pageY : document.body.scrollTop+event.clientY
flag=1
}
function makesnake() {
if (flag==1 && document.all) {
for (i=message.length-1; i>=1; i--) {
xpos[i]=xpos[i-1]+step
ypos[i]=ypos[i-1]
}
xpos[0]=x+step
ypos[0]=y
for (i=0; i<message.length-1; i++) {
var thisspan = eval("span"+(i)+".style")
thisspan.posLeft=xpos[i]
thisspan.posTop=ypos[i]
}
}
else if (flag==1 && document.layers) {
for (i=message.length-1; i>=1; i--) {
xpos[i]=xpos[i-1]+step
ypos[i]=ypos[i-1]
}
xpos[0]=x+step
ypos[0]=y
for (i=0; i<message.length-1; i++) {
var thisspan = eval("document.span"+i)
thisspan.left=xpos[i]
thisspan.top=ypos[i]
}
}
var timer=setTimeout("makesnake()",30)
}
</script>
<script>
<!-- Beginning of JavaScript -
for (i=0;i<=message.length-1;i++) {
document.write("<span id='span"+i+"' class='spanstyle'>")
document.write(message[i])
document.write("</span>")
}
if (document.layers){
document.captureEvents(Event.MOUSEMOVE);
}
document.onmousemove = handlerMM;
// - End of JavaScript - -->
</script>
<script
language="JavaScript"><!--
var
h=(Math.random()*10);
if (h
<1) document.writeln("Жена встает на
весы. Муж ухмыляется, глядя на стрелку. <BR> - Ты знаешь, какой у тебя должен быть рост,
чтобы соответствовать весу? <br>
- Какой? <br> - Пять
метров!");
if (h > 1 && h < 2) document.writeln("- У меня брат в
Академии наук,- похвастался другу чукча. <BR> - И что он там изучает? <br> - Там его изучают.");
if (h > 2 && h < 3) document.writeln("- Алло! Это морг? <BR> - Да! <br> - Позовите гришу с третей полки.");
if (h > 3 && h < 4) document.writeln("В ресторане: <BR> - Дайте мне, пожалуйста, булочку с маком.
<br> - А может быть,
батон с героином?");
if (h > 4 && h < 5) document.writeln("Внук спрашивает:
<BR> - Бабушка, а Сталин
хороший? <br> - Нет! <br> - А Брежнев? <br> - Плохой! <br> - А Ельцин? <br> - Умрет, тогда видно будет.");
if (h > 5 && h < 6) document.writeln("За организацию
убийства своего компаньона ''нового русского'' приговорили к смертной казни.
<BR> - По закону мы
можем выполнить вашу последнюю просьбу,- говорит судебный исполнитель. <br> - Предоставьте мне возможность посмотреть
''Санта-Барбару'' до конца.");
if (h > 6 && h < 7) document.writeln("Поймал ''новый
русский'' золотую рыбку. <BR>
- Ну, рыбка, чего хочешь?");
if (h > 7 && h < 8) document.writeln("- Вы хотели
скрыть от государства большую часть своих доходов,- говорит налоговый инспектор
''новому русскому''. <BR>
Я не виноват, что в графу ''доходы'' все нули не поместились!");
if (h > 8 && h < 9) document.writeln("Больница. В палате лежит мужчина,
весь в гипсе, с руками и ногами на подвесках и диктует письмо: ''Уважаемый
издатель! На странице 14 Вашей инструкции ''Как управлять вертолетом'' мною
была обнаружена опечатка...''");
if (h > 9 && h <10) document.writeln("Учителница
Вовочке: <BR> - Я задала
сочинение о молоке на четыре страниы, а ты написал лишь на страницу. <br> - Я писал о сгущеном молоке.");
//
--></script>
Этот
скрипт создает на странице эффект падающего снега (листьев и т.д.).
Можно вставить в страницу
весь скрипт и при этом использывать любые свои рисунки.
При этом можно регулировать количество и скорость снежинок.
<SCRIPT LANGUAGE="JavaScript1.2">
<!-- Begin
var no = 35; //
колличество снежинок
var speed = 6; // скорость
снежинок
var snowflake = "sneg.gif";
var ns4up = (document.layers) ? 1 : 0;
var ie4up = (document.all) ? 1 : 0;
var dx, xp, yp;
var am, stx, sty;
var i, doc_width = 800, doc_height = 600;
if (ns4up) {
doc_width = self.innerWidth;
doc_height = self.innerHeight;
} else if (ie4up) {
doc_width = document.body.clientWidth;
doc_height = document.body.clientHeight;
}
dx = new Array();
xp = new Array();
yp = new Array();
am = new Array();
stx = new Array();
sty = new Array();
for (i = 0; i < no; ++ i) {
dx[i] = 0;
xp[i] = Math.random()*(doc_width-50);
yp[i] = Math.random()*doc_height;
am[i] = Math.random()*20;
stx[i] = 0.02 + Math.random()/10;
sty[i] = 0.7 + Math.random();
if (ns4up) {
if (i == 0) {
document.write("<layer name=\"dot"+ i +"\" left=\"15\" ");
document.write("top=\"15\" visibility=\"show\"><img src=\"");
document.write(snowflake + "\" border=\"0\"></layer>");
} else {
document.write("<layer name=\"dot"+ i +"\" left=\"15\" ");
document.write("top=\"15\" visibility=\"show\"><img src=\"");
document.write(snowflake + "\" border=\"0\"></layer>");
}
} else if (ie4up) {
if (i == 0) {
document.write("<div id=\"dot"+ i +"\" style=\"POSITION: ");
document.write("absolute; Z-INDEX: "+ i +"; VISIBILITY: ");
document.write("visible; TOP: 15px; LEFT: 15px;\"><img src=\"");
document.write(snowflake + "\" border=\"0\"></div>");
} else {
document.write("<div id=\"dot"+ i +"\" style=\"POSITION: ");
document.write("absolute; Z-INDEX: "+ i +"; VISIBILITY: ");
document.write("visible; TOP: 15px; LEFT: 15px;\"><img src=\"");
document.write(snowflake + "\" border=\"0\"></div>");
}
}
}
function snowNS() {
for (i = 0; i < no; ++ i) {
yp[i] += sty[i];
if (yp[i] > doc_height-50) {
xp[i] = Math.random()*(doc_width-am[i]-30);
yp[i] = 0;
stx[i] = 0.02 + Math.random()/10;
sty[i] = 0.7 + Math.random();
doc_width = self.innerWidth;
doc_height = self.innerHeight;
}
dx[i] += stx[i];
document.layers["dot"+i].top = yp[i];
document.layers["dot"+i].left = xp[i] + am[i]*Math.sin(dx[i]);
}
setTimeout("snowNS()", speed);
}
function snowIE() {
for (i = 0; i < no; ++ i) {
yp[i] += sty[i];
if (yp[i] > doc_height-50) {
xp[i] = Math.random()*(doc_width-am[i]-30);
yp[i] = 0;
stx[i] = 0.02 + Math.random()/10;
sty[i] = 0.7 + Math.random();
doc_width = document.body.clientWidth;
doc_height = document.body.clientHeight;
}
dx[i] += stx[i];
document.all["dot"+i].style.pixelTop = yp[i];
document.all["dot"+i].style.pixelLeft = xp[i] + am[i]*Math.sin(dx[i]);
}
setTimeout("snowIE()", speed);
}
if (ns4up) {
snowNS();
} else if (ie4up) {
snowIE();
}
// End -->
</script>