Продвижение интернет сайтов

Обмен статьями и ссылками
Главная
Уроки
Конспекты
Хостинг
Контакты



Скрипты


Рано или поздно Вам потребуются различные скрипты для Вашего сайта, здесь я выложил несколько таких. Эти скрипты написаны на языке JavaScript.

Скрипт редиректа (перенаправление пользователя на другой сайт)
Калькулятор
Меняет курсор при наведении на ссылку
Добавить в избранное
Показать дату
Довольно неплохое меню
Дайте возможность поменять цвет фона Вашего сайта :)
Этот скрипт блокирует правую кнопку мыши
Простой скрипт скроллинга текста

Gif анимация


Скрипт редиректа (перенаправление пользователя на другой сайт):

<META HTTP-EQUIV="Refresh" CONTENT="0; URL=http://ваш_сайт.ru">

Калькулятор

<CENTER>
<FORM name="Keypad">
<TABLE>
<TABLE border=2 width=50 cellpadding=1 cellspacing=5 bgcolor="#660000">
<TR>
<TD colspan=3><input name="ReadOut" type="Text" size=24 value="0">
</TD>
<TD>
</TD>
</TD>
<TD><input name="btnClear" type="Button" value=" C " onclick="Clear()">
</TD>
<TD><input name="btnClearEntry" type="Button" value=" CE " onclick="ClearEntry()">
</TD>
</TR>
<TR>
<TD><input name="btnSeven" type="Button" value=" 7 " onclick="NumPressed(7)">
</TD>
<TD><input name="btnEight" type="Button" value=" 8 " onclick="NumPressed(8)">
</TD>
<TD><input name="btnNine" type="Button" value=" 9 " onclick="NumPressed(9)">
</TD>
<TD></TD>
<TD><input name="btnNeg" type="Button" value=" +/- " onclick="Neg()">
</TD>
<TD><input name="btnPercent" type="Button" value=" % " onclick="Percent()">
</TD>
</TR>
<TR>
<TD><input name="btnFour" type="Button" value=" 4 " onclick="NumPressed(4)">
</TD>
<TD><input name="btnFive" type="Button" value=" 5 " onclick="NumPressed(5)">
</TD>
<TD><input name="btnSix" type="Button" value=" 6 " onclick="NumPressed(6)">
</TD>
<TD></TD>
<TD><input name="btnPlus" type="Button" value=" + " onclick="Operation('+')">
</TD>
<TD><input name="btnMinus" type="Button" value=" - " onclick="Operation('-')">
</TD>
</TR>
<TR>
<TD><input name="btnOne" type="Button" value=" 1 " onclick="NumPressed(1)">
</TD>
<TD><input name="btnTwo" type="Button" value=" 2 " onclick="NumPressed(2)">
</TD>
<TD><input name="btnThree" type="Button" value=" 3 " onclick="NumPressed(3)">
</TD>
<TD></TD>
<TD><input name="btnMultiply" type="Button" value=" * " onclick="Operation('*')">
</TD>
<TD><input name="btnDivide" type="Button" value=" / " onclick="Operation('/')">
</TD>
</TR>
<TR>
<TD><input name="btnZero" type="Button" value=" 0 " onclick="NumPressed(0)">
</TD>
<TD><input name="btnDecimal" type="Button" value=" . " onclick="Decimal()">
</TD>
<TD colspan=3></TD>
<TD><input name="btnEquals" type="Button" value=" = " onclick="Operation('=')">
</TD>
</TR>
</TABLE>
</TABLE>
</FORM>
</CENTER>
<SCRIPT LANGUAGE="JavaScript">
<!--
var FKeyPad = document.Keypad;
var Accum = 0;
var FlagNewNum = false;
var PendingOp = "";
function NumPressed (Num) {
if (FlagNewNum) {
FKeyPad.ReadOut.value = Num;
FlagNewNum = false;
}
else {
if (FKeyPad.ReadOut.value == "0")
FKeyPad.ReadOut.value = Num;
else
FKeyPad.ReadOut.value += Num;
}
}
function Operation (Op) {
var Readout = FKeyPad.ReadOut.value;
if (FlagNewNum && PendingOp != "=");
else
{
FlagNewNum = true;
if ( '+' == PendingOp )
Accum += parseFloat(Readout);
else if ( '-' == PendingOp )
Accum -= parseFloat(Readout);
else if ( '/' == PendingOp )
Accum /= parseFloat(Readout);
else if ( '*' == PendingOp )
Accum *= parseFloat(Readout);
else
Accum = parseFloat(Readout);
FKeyPad.ReadOut.value = Accum;
PendingOp = Op;
}
}
function Decimal () {
var curReadOut = FKeyPad.ReadOut.value;
if (FlagNewNum) {
curReadOut = "0.";
FlagNewNum = false;
}
else
{
if (curReadOut.indexOf(".") == -1)
curReadOut += ".";
}
FKeyPad.ReadOut.value = curReadOut;
}
function ClearEntry () {
FKeyPad.ReadOut.value = "0";
FlagNewNum = true;
}
function Clear () {
Accum = 0;
PendingOp = "";
ClearEntry();
}
function Neg () {
FKeyPad.ReadOut.value = parseFloat(FKeyPad.ReadOut.value) * -1;
}
function Percent () {
FKeyPad.ReadOut.value = (parseFloat(FKeyPad.ReadOut.value) / 100) * parseFloat(Accum);
}
// -->
</SCRIPT>

Меняет курсор при наведении на ссылку

<style type="text/css"> </style><font face="impact" size="4"color="100
9CC">
<a href="http://www.sait.ru"
style="cursor:crosshair">www.sait.ru</a>

Добавить в избранное

<a href="javascript:window.external.AddFavorite('http://www.Ваш сайт.ru/', 'Название Вашего сайта');">В Избранное</a>

Показать дату

<SCRIPT LANGUAGE="javascript">

var now = new Date();
var textout;
var month = now.getMonth();
var date = now.getDate();

if (month==0) textout="январь";
if (month==1) textout="февраль";
if (month==2) textout="март";
if (month==3) textout="апрель";
if (month==4) textout="май";
if (month==5) textout="июнь";
if (month==6) textout="июль";
if (month==7) textout="август";
if (month==8) textout="сентябрь";
if (month==9) textout="октябрь";
if (month==10) textout="ноябрь";
if (month==11) textout="декабрь";

textout += ", " + date;
document.write ("<font size=2 color=202020><strong>Сегодня " + textout + "-е число.</strong></font>");
</script>

Довольно неплохое меню

<Script Language="JavaScript">
document.write("<Center>");
document.write("<Form Name=\"Kolory\">");
document.write("<Select Name=\"schemesel\" OnChange=\"document.bgColor = this.options[selectedIndex].value\">");
document.write("<Option Value=\"ffffff\" selected>Белый");
document.write("<Option Value=\"0000ff\">Синий");
document.write("<Option Value=\"a0a0a0\">Серый");
document.write("<Option Value=\"e9e900\">Желтый");
document.write("<Option Value=\"a0a0ff\">Пурпур");
document.write("<Option Value=\"c70000\">Красный");
document.write("<Option Value=\"ffffa0\">Коричневый");
document.write("<Option Value=\"f0f0fa\">Стальной");
document.write("<Option Value=\"ff00ff\">Сиреневый");
document.write("<Option Value=\"00ffff\">Небесный");
document.write("</Select>");
document.write("</Form>");
document.write("</Center>");
</Script>

Дайте возможность поменять цвет фона Вашего сайта :)

<script language=javascript>
function showObject() {
document.all.div1.className = 'go';
}
function hideObject() {
document.all.div1.className = 'pop';
}
function showObject2() {
document.all.div2.className = 'go';
}
function hideObject2() {
document.all.div2.className = 'pop';
}
function showObject3() {
document.all.div3.className = 'go';
}
function hideObject3() {
document.all.div3.className = 'pop';
}
</script>


<table>
<tr><td>
<div style="background-color:silver; width:140" onmouseover="showObject()" onmouseout="hideObject()" >
<a href=# onmouseover="showObject()" onmouseout="hideObject()">Search</a>
</div>
<div id=div1 onmouseover="showObject()" onmouseout="hideObject()" class=pop style="background-color:#E8FED8; width:140">
<a href=http://www.lycos.com onmouseover="showObject()" onmouseout="hideObject()">Lycos</a><br>
<a href=http://www.yahoo.com onmouseover="showObject()" onmouseout="hideObject()">Yahoo</a><br>
<a href=http://www.excite.com onmouseover="showObject()" onmouseout="hideObject()">Excite</a><br>
<font color=#E8FED8>|</font>
</div>
</td><td>
<div style="background-color:silver; width:140" onmouseover="showObject2()" onmouseout="hideObject2()" >
<a href=# onmouseover="showObject2()" onmouseout="hideObject2()">Browsers</a>
</div>
<div id=div2 onmouseover="showObject2()" onmouseout="hideObject2()" class=pop style="background-color:#E8FED8; width:140">
<a href=http://www.netscape.com onmouseover="showObject2()" onmouseout="hideObject2()">Netscape</a><br>
<a href=http://www.microsoft.com onmouseover="showObject2()" onmouseout="hideObject2()">IE</a><br>
<font color=#E8FED8>|<Br>
|</font>
</div>
</td><td>
<div style="background-color:silver; width:140" onmouseover="showObject3()" onmouseout="hideObject3()" >
<a href=# onmouseover="showObject3()" onmouseout="hideObject3()">Music</a>
</div>
<div id=div3 onmouseover="showObject3()" onmouseout="hideObject3()" class=pop style="background-color:#E8FED8; width:140">
<a href=http://www.winamp.com onmouseover="showObject3()" onmouseout="hideObject3()">Winamp</a><br>
<a href=http://www.realplayer.com onmouseover="showObject3()" onmouseout="hideObject3()">RealPlayer</a><br>
<font color=#E8FED8>|<br>
|</font>
</div>
</td></tr></table>

Этот скрипт блокирует правую кнопку мыши

<SCRIPT language=Javascript1.2>
<!--
var message='У вас не работает правая кнопка мыши!';
function click(e)
{if (document.all) {if (event.button == 2) {alert(message);return false;}}
if (document.layers) {if (e.which == 3) {alert(message);return false;}}}
if (document.layers) {document.captureEvents(Event.MOUSEDOWN);}
document.onmousedown=click;
// -->
</SCRIPT>
<CENTER>Проверьте правую кнопку мыши!</CENTER>
<CENTER>Кажется, она сломалась!</CENTER>

Простой скрипт скроллинга

<script language="JavaScript1.2">

var message= new Array()

message[0]="Простой скрипт скролинга текста|Можно вставлять ссылки, количество сообщений неограниченно|http://case.agava.ru"

message[1]="Clinton Bashes NY Mayor|Speaking to 1,000 teacher aides on Saturday, Hillary Rodham Clinton attacked Mayor Rudolph Giuliani's positions on education.|http://case.agava.ru"

message[2]="House Bill Curbs Sex Slavery|A House bill designed to protect victims of the growing international sex slavery trade would allow child victims brought to this country to stay in America.|http://case.agava.ru"

// The height of the scrollerbox (pixels)
var scrollerheight=160

// The width of the scrollerbox (pixels)
var scrollerwidth=160

// The distance to the left border of the window (pixels)
var scrollertop=20

// The distance to the top border of the window (pixels)
var scrollerleft=20

// The padding between the scrollerbox and the text (pixels)
var scrollerpadding=10

// The width of the scrollerbox-border (pixels)
var backgroundborder=2

// The background-colour of the scrollerbox
var scrollerbgcolor="DDDDDD"

// Font attributes of the title
var font_titleface="Verdana"
var font_titlecolor="FF0000"
var font_titlesize=1

// Font attributes of the copytext
var font_copyface="Verdana"
var font_copycolor="660000"
var font_copysize=1

// standstill between the messages (milliseconds)
var standstillfix=3000

// Do not edit below this line
var cliptop=0
var clipbottom=scrollerheight-2*scrollerpadding
var clipleft=0
var clipright=scrollerheight

var i_message=0
var mes_joined
var mes_split
var contenttext
var contentbg

var totalheight=scrollerheight*(message.length)
var i_height=0
var step=1
var pause=20

var standstillflex=0

function initiate(){
contenttext="<table cellpadding=0 cellspacing=0 border=0 width="+(scrollerwidth-2*scrollerpadding)+">"
contenttext+="<tr valign='top'><td height='"+scrollerheight+"'><br></td></tr>"
for (i=0;i<=message.length-1;i++) {
mes_joined=message[i]
mes_split=mes_joined.split("|")
contenttext+="<tr valign='top'><td height='"+scrollerheight+"'><a href='"+mes_split[2]+"'><font face='"+font_titleface+"' color='"+font_titlecolor+"' size='"+font_titlesize+"'>"+mes_split[0]+"</font></a><br><font face='"+font_copyface+"' color='"+font_copycolor+"' size='"+font_copysize+"'>"+mes_split[1]+"</font></td></tr>"
}
contenttext+="</table>"

contentbg="<table cellpadding=0 cellspacing=0 border="+backgroundborder+" width='"+scrollerwidth+"'><tr><td height='"+scrollerheight+"' bgcolor="+scrollerbgcolor+"> </td></tr></table>"

if (document.all) {
scrollertext.innerHTML=contenttext
scrollerbg.innerHTML=contentbg
document.all.scrollertext.style.posTop=scrollertop
document.all.scrollertext.style.posLeft=scrollerleft
document.all.scrollerbg.style.posTop=scrollertop-scrollerpadding
document.all.scrollerbg.style.posLeft=scrollerleft-scrollerpadding
document.all.scrollertext.style.clip="rect("+cliptop+" "+clipright+" "+clipbottom+" "+clipleft+")"
}
if (document.layers) {
document.scrollertext.document.write(contenttext)
document.scrollertext.document.close()
document.scrollerbg.document.write(contentbg)
document.scrollerbg.document.close()
document.scrollertext.top=scrollertop
document.scrollertext.left=scrollerleft
document.scrollerbg.top=scrollertop-scrollerpadding
document.scrollerbg.left=scrollerleft-scrollerpadding
document.scrollertext.clip.left=clipleft
document.scrollertext.clip.right=clipright
document.scrollertext.clip.top=cliptop
document.scrollertext.clip.bottom=clipbottom
}
scroll()


} function scroll(){
standstillflex=standstillfix
if (document.all){
if (i_height<scrollerheight) {
i_height+=step
cliptop+=step
clipbottom+=step
document.all.scrollertext.style.clip="rect("+cliptop+" "+clipright+" "+clipbottom+" "+clipleft+")"
document.all.scrollertext.style.posTop-=step
var timer=setTimeout("scroll()",pause)
}

else {
if (document.all.scrollertext.style.posTop<=-(totalheight)) {
document.all.scrollertext.style.posTop=scrollertop
cliptop=0
clipbottom=scrollerheight-2*scrollerpadding
document.all.scrollertext.style.clip="rect("+cliptop+" "+clipright+" "+clipbottom+" "+clipleft+")"
standstillflex=0
}
i_height=0
clearTimeout(timer)
var timer=setTimeout("scroll()",standstillflex)
}
}

if (document.layers){
if (i_height<scrollerheight) {
i_height+=step
cliptop+=step
clipbottom+=step
document.scrollertext.clip.left=clipleft
document.scrollertext.clip.right=clipright
document.scrollertext.clip.top=cliptop
document.scrollertext.clip.bottom=clipbottom
document.scrollertext.top-=step
var timer=setTimeout("scroll()",pause)
}

else {
if (document.scrollertext.top<=-(totalheight)) {
document.scrollertext.top=scrollertop
cliptop=0
clipbottom=scrollerheight-2*scrollerpadding
document.scrollertext.clip.left=clipleft
document.scrollertext.clip.right=clipright
document.scrollertext.clip.top=cliptop
document.scrollertext.clip.bottom=clipbottom
standstillflex=0
}
i_height=0
clearTimeout(timer)
var timer=setTimeout("scroll()",standstillflex)
}
}
}

</script>








| Главная | История HTML | Зачем нужен сайт | Уроки | Конспекты | Практическая работа | Тест | Скрипты | О хостинге | Контакты |