Показаны сообщения с ярлыком СКРИПТЫ. Показать все сообщения
Показаны сообщения с ярлыком СКРИПТЫ. Показать все сообщения

Изменение цвета фона по ссылке

При наведении мышки к ссылке с указнным цветом, этим цветом “заливается” фон страницы.
<!– START OF SCRIPT –>

<a href=”" onMouseover=”document.bgColor=’red’”>Red</a><br><a href=”" onMouseover=”document.bgColor=’orange’”>Orange</a><br> <a href=”" onMouseover=”document.bgColor=’yellow’”>Yellow</a><br> <a href=”" onMouseover=”document.bgColor=’green’”>Green</a><br> <a href=”" onMouseover=”document.bgColor=’blue’”>Blue</a><br> <a href=”" onMouseover=”document.bgColor=’purple’”>Purple</a><br>
<!– END OF SCRIPT –>

Ссылка с указателем


При наведении на ссылку рисунок возле неё изменяется на другой. Можно сделать 1ый рисунок как обычный квадратик под цвет фона, а второй в виде анимированной стрелки – получится неплохо.

<SCRIPT LANGUAGE=”JavaScript”>
<!– Original: (mrenner@rst.de) –>
<!– Begin
function imgover(imgname){
imgname.src = “arrow.gif”
}
function imgout(imgname){
imgname.src = “blank.gif”
}
// End –>
</SCRIPT>
<center>
<table border=0>
<tr><td>
<img name=”pic1″ SRC=”blank.gif” width=10 height=10 border=0>
<A HREF=”http://altavista.digital.com” onMouseOver=”imgover(pic1)” onMouseOut=”imgout(pic1)”>Altavista</A>
<br>
<img name=”pic2″ SRC=”blank.gif” width=10 height=10 border=0>
<A HREF=”http://www.excite.com” onMouseOver=”imgover(pic2)” onMouseOut=”imgout(pic2)”>Excite</A>
<br>
<img name=”pic3″ SRC=”blank.gif” width=10 height=10 border=0>
<A HREF=”http://www.hotbot.com” onMouseOver=”imgover(pic3)” onMouseOut=”imgout(pic3)”>Hotbot</A>
<br>
<img name=”pic4″ SRC=”blank.gif” width=10 height=10 border=0>
<A HREF=”http://www.infoseek.com” onMouseOver=”imgover(pic4)” onMouseOut=”imgout(pic4)”>Infoseek</A>
<br>
<img name=”pic5″ SRC=”blank.gif” width=10 height=10 border=0>
<A HREF=”http://www.lycos.com” onMouseOver=”imgover(pic5)” onMouseOut=”imgout(pic5)”>Lycos</A>
<br>
<img name=”pic6″ SRC=”blank.gif” width=10 height=10 border=0>
<A HREF=”http://www.magellan.com” onMouseOver=”imgover(pic6)” onMouseOut=”imgout(pic6)”>Magellan</A>
<br>
<img name=”pic7″ SRC=”blank.gif” width=10 height=10 border=0>
<A HREF=”http://www.webcrawler.com” onMouseOver=”imgover(pic7)” onMouseOut=”imgout(pic7)”>Webcrawler</A>
<br>
<img name=”pic8″ SRC=”blank.gif” width=10 height=10 border=0>
<A HREF=”http://www.yahoo.com” onMouseOver=”imgover(pic8)” onMouseOut=”imgout(pic8)”>Yahoo!</A>
</td></tr></table>
</center>

TCM

Очень красивый скрипт: за курсором мышки летают буквы, причём не абы как, а в зависимости от того, с какой скоростью вы “дёргаете” мышь. Настраивается всё: от типа шрифта до скорости полёта.

<style>.spanstyle {
position:absolute;
visibility:visible;
top:-50px;
font-size:12pt;
font-family:Verdana;
font-weight:bold;
color:#00FF00;
}</style><body onLoad=”makesnake()” style=”width:100%;overflow-x:hidden;overflow-y:scroll background=”images/fon4.gif”
vlink=”#0000FF”></body><script>var x,y
var step=16
var flag=0
var message=”korgick’s site ”
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()”,15)
}</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;</script>

Тескстовый банер


Текст едет слева направо, потом оттлалкивается от края формы, едет обратно и оттлакивается другого края …и т.д.

Селектор ссылок

При помощи этого скрипта группа радио-кнопок связывается с одной ссылкой, и достаточно сделать выбор и нажать на ссылку.

<!– START OF SCRIPT –>
<SCRIPT LANGUAGE=”JavaScript”>
<!–HIDE
function changeIt(newLoc) {
document.links[0].href=newLoc
}
//STOP HIDING–>
</SCRIPT>
<FORM>Выберите ссылку:<br>
<INPUT TYPE=”radio” NAME=”choices” onClick=
“changeIt(‘http://второй адрес’)”>
Первая<br>
<INPUT TYPE=”radio” NAME=”choices” onClick=
“changeIt(‘http://третий адрес’)”>
Вторая<br>
<INPUT TYPE=”radio” NAME=”choices” onClick=
“changeIt(‘http://четвертый адрес’)”>
Третья<br>
<A HREF=”http://первый адрес”>
Нажмите здесь для перехода</A>

<!– END OF SCRIPT –>

Тряска


Ваш броузер трясётся при наведении на ссылку. Довольно прикольно

<center><form>
<img src=”images/exit.gif” value=”Закрыть окно” onClick=”javascript:exit()”>
</form>
<script>
function exit(){
close();
}
</script></center>

Вертикальная прокрутка окна

<!– START OF SCRIPT –>
<SCRIPT Language=”JavaScript”>
<!–
function scrollit(){
for (I=1; I<=500; I++){
parent.scroll(1,I)
}
}
//–>
</SCRIPT>

</HEAD>
<form>
<input type=button value=”ScrollDown” onClick=”scrollit()”>
</form>
<hr>
<Center>
<BR><BR><BR><BR><BR><BR><BR><BR>
<H1>Welcome to JavaScript Planet</H1>
<BR><BR><BR><BR><BR><BR><BR><BR>
<H1>ScrollDown is a very simple JavaScript…</H1>
<BR><BR><BR><BR><BR><BR><BR><BR>
<H1>..but the effect is quite cool!</H1>
<!– END OF SCRIPT –>

ЗАПРЕТ КОПИРОВАНИЯ

<script language='JavaScript'>
<!--
//Disable right mouse click Script
//By Maximus (maximus@nsimail.com) w/ mods by DynamicDrive
//For full source code, visit http://www.dynamicdrive.com
var message="No Right-Click!";
///////////////////////////////////
function clickIE4(){
if (event.button==2){
alert(message);
return false;
}
}
function clickNS4(e){
if (document.layers||document.getElementById&&!document.all){
if (e.which==2||e.which==3){
alert(message);
return false;
}
}
}
if (document.layers){
document.captureEvents(Event.MOUSEDOWN);
document.onmousedown=clickNS4;
}
else if (document.all&&!document.getElementById){
document.onmousedown=clickIE4;
}
document.oncontextmenu=new Function("alert(message);return false")
// -->
</script>
<!-- Начнём с самого простого скрипта, ЗАЩИТА ОТ КЭШИРОВАНИЯ: -->
<meta http-equiv="pragma" content="no-cache"/>

<!-- Следующий скрипт - ЗАЩИТА ОТ КОПИРОВАНИИ ИНФОРМАЦИИ -->
<script language=JavaScript>
function notcopy(){
alert("Извините, но с этой страницы нельзя ничего копировать!")
return false
}
</script>

<!-- Ну этот код очень полезный - Защита от перетаскивания и выделения текста. -->
<script language=javaScript>document.onselectstart=new Function("return false");

document.ondragstart=new Function("return false");</script>

Текст в фиксированном положении

Текст закрепляется в заданном месте на страничке и при прокрутке онкна остаётся на месте.
function exit(){
close();
}
</script></center>
<script>
/*
Always-on-top message Script-
© Dynamic Drive (www.dynamicdrive.com)
For full source code, installation instructions,
100′s more DHTML scripts, and Terms Of
Use, visit dynamicdrive.com
*/
//enter the message you wish to be shown, including html tags
var message=’<b><font color=000000 size=5>Этот текст всегда будет расположен внизу экрана!</font></b>’
//enter a color name to be used as the background color of the message
var backgroundcolor=”blue”
//enter 0 for always display, 1 for a set period, 2 for random display mode
var displaymode=0
//if displaymode is set to display for a set period, enter the period below (1000=1 sec)
var displayduration=10000
//enter 0 for non-flashing message, 1 for flashing
var flashmode=1
//if above is set to flashing, enter the flash-to color below
var flashtocolor=”lightcyan”
///////////////do not edit below this line////////////////////////////////////////
function regenerate(){
window.location.reload()
}
var which=0
function regenerate2(){
if (document.layers)
setTimeout(“window.onresize=regenerate”,400)
}
function display2(){
if (document.layers){
if (topmsg.visibility==”show”)
topmsg.visibility=”hide”
else
topmsg.visibility=”show”
}
else if (document.all){
if (topmsg.style.visibility==”visible”)
topmsg.style.visibility=”hidden”
else
topmsg.style.visibility=”visible”
setTimeout(“display2()”,Math.round(Math.random()*10000)+10000)
}
}
function flash(){
if (which==0){
if (document.layers)
topmsg.bgColor=flashtocolor
else
topmsg.style.backgroundColor=flashtocolor
which=1
}
else{
if (document.layers)
topmsg.bgColor=backgroundcolor
else
topmsg.style.backgroundColor=backgroundcolor
which=0
}
}
if (document.all){
document.write(‘<span id=”topmsg” style=”position:absolute;visibility:hidden”>’+message+’</span>’)
}
function logoit(){
document.all.topmsg.style.left=document.body.scrollLeft+document.body.clientWidth/2-document.all.topmsg.offsetWidth/2
document.all.topmsg.style.top=document.body.scrollTop+document.body.clientHeight-document.all.topmsg.offsetHeight-4
}
function logoit2(){
topmsg.left=pageXOffset+window.innerWidth/2-topmsg.document.width/2
topmsg.top=pageYOffset+window.innerHeight-topmsg.document.height-5
setTimeout(“logoit2()”,90)
}
function setmessage(){
document.all.topmsg.style.left=document.body.scrollLeft+document.body.clientWidth/2-document.all.topmsg.offsetWidth/2
document.all.topmsg.style.top=document.body.scrollTop+document.body.clientHeight-document.all.topmsg.offsetHeight-4
document.all.topmsg.style.backgroundColor=backgroundcolor
document.all.topmsg.style.visibility=”visible”
if (displaymode==1)
setTimeout(“topmsg.style.visibility=’hidden’”,displayduration)
else if (displaymode==2)
display2()
if (flashmode==1)
setInterval(“flash()”,1000)
window.onscroll=logoit
window.onresize=new Function(“window.location.reload()”)
}
function setmessage2(){
topmsg=new Layer(window.innerWidth)
topmsg.bgColor=backgroundcolor
regenerate2()
topmsg.document.write(message)
topmsg.document.close()
logoit2()
topmsg.visibility=”show”
if (displaymode==1)
setTimeout(“topmsg.visibility=’hide’”,displayduration)
else if (displaymode==2)
display2()
if (flashmode==1)
setInterval(“flash()”,1000)
}
if (document.layers)
window.onload=setmessage2
else if (document.all)
window.onload=setmessage

</script>

Всплывающее окно при входе на сайт

<style>
#popup {
  display: table;
  position: fixed; top: 0; left: 0;
  z-index: 100;
  height: 100%;
  width: 100%;
  background: rgba(240,240,240,.9);
  visibility: hidden;
  animation: animaciya 1s 5s forwards; /* 5s - это количество секунд по истечении которых появляется сообщение */
  cursor: pointer;
}
@keyframes animaciya {  
  from {visibility: hidden;} 
  to {visibility: visible;}
}
#popup figure {
  display: table-cell;
  vertical-align: middle;
}
#popup div, #popup figcaption, #popup figure:before {
  max-width: 500px; /* максимальная ширина */
  margin: 0 auto;
  border-style: solid;
  border-color: rgb(88,125,164);
  background: #fff;
}
#popup figure:before { /* стиль кнопки "закрыть" */
  content: "закрыть";
  display: block;
  padding: 0 1%;
  border-width: 4px 4px 0 4px;
  border-radius: 5px 5px 0 0;
  text-align: right;
  color: rgb(88,125,164);
}
#popup div, #popup figcaption {
  padding: 1%;
  cursor: default;
}
#popup figcaption {
  position: relative;
  border-width: 0 4px 0 4px;
  font-size: 150%;
  text-transform: uppercase;
  color: rgb(100,100,100);
}
#popup figcaption:before { /* стиль восклицательного знака, не поддерживается Google Chrome. Его можно заменить на что-то более приемлемое */
  content: "\26a0 \20 \20";
  color: red;
  font-size: 150%;
  vertical-align: middle;
}
#popup div {
  border-width: 0 4px 4px 4px;
  border-radius: 0 0 5px 5px;
}
</style>

<div id="popup">
  <figure>
    <figcaption>ДОРОГОЙ ГОСТЬк</figcaption>
    <div><div class="p1">
<span class="s1">Мы рады сообщить Вам об открытии официального Представительства в России и стран СНГ косметической линии&nbsp;</span>Sea of SPA, которая занимается разработкой оздоровительных и косметических средств на основе новейших технологий.&nbsp;</div>
<div class="p2">
Главными приоритетами нашей компании мы считаем<span class="s2">:</span></div>
<ul class="ul1">
<li class="li3">Широкий ассортимент и его постоянное пополнение;</li>
<li class="li3">Индивидуальный подход к каждому клиенту;&nbsp;</li>
<li class="li3">Гибкая ценовая политика, обусловленная прямыми поставками от производителей;</li>
<li class="li3">Возможность создать свой бизнес ,который принесет Вам финансовую стабильность.</li>
</ul>
<div class="p4">
<br /></div>
<div class="p3">
1 сентября 2013 года мы открываем для вас двери и будем рады окружить всех вас своим вниманием и заботой.</div>
<div class="p4">
<br /></div>
<div class="p3">
Сегодня проходит предварительная регистрация желающих преуспеть в компании, развивая свой бизнес.&nbsp;</div>
<div class="p7">
<b>Поднимите престиж своего бизнеса с помощью самой натуральной на земле косметики Мертвого Моря.&nbsp;</b></div>
<br />
<div class="p7">
<b>Здоровье и жизненная сила с 417 метров ниже уровня мирового океана!</b></div>
</div></div>
  </figure>
</div>

<script>
window.onkeyup = okno; // нажатие Esc, см. условие "e.keyCode==27"
document.getElementById('popup').onclick = okno;

function okno(e) {
  if (e.target.nodeName != 'DIV' && e.target.nodeName != 'FIGCAPTION' || e.keyCode==27) { // через && перечисляются теги, клинкув на которые окно не будет закрыто; сюда же можно включить тег A или IFRAME
    document.getElementById('popup').style.display='none';
    localStorage.setItem('popup1', 'none');
  }
}

if(localStorage.getItem('popup1')) {
  document.getElementById('popup').style.display='none';
}

</script>

Ссылка-банер

Ссылка мигает, плавно изменяет свой цвет и меняется сама.
<style>
<!–
#tickertape{
position:relative;
layer-background-color:black;
width:400;
height:12;
}
#subtickertape{
background-color:black;
position:absolute;
border: 1px solid black;
width:400;
height:12;
}
.subtickertapefont{
font:bold 12px Verdana;
text-decoration:none;
color:white;
}
.subtickertapefont a{
color:white;
text-decoration:none;
}
–>
</style>
<body onload=”if (document.all||document.layers) {regenerate2();update()}”>
<div id=”tickertape”>
<div id=”subtickertape”>Initializing…</div>
</div>
<script language=”JavaScript1.2″>
/*
Fading Ticker Tape Script-
© Dynamic Drive (www.dynamicdrive.com)
Fading background color component by Dave Methvin, Windows Magazine
For full source code, installation instructions,
100′s more DHTML scripts, and Terms Of
Use, visit dynamicdrive.com
*/
//default speed is 4.5 seconds, Change that as desired
var speed=4500
var news=new Array()
news[0]=”<a href=’http://dynamicdrive.com’>Click here to go to Dynamic Drive’s front page</a>”
news[1]=”<a href=’http://wsabstract.com’>Visit Website Abstraction for free JavaScripts!</a>”
news[2]=”<a href=’http://freewarejava.com’>Looking for free java applets? Click here.</a>”
//expand or shorten this list of messages as desired
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, 0×00,0×00,0×00,10);
if (document.layers){
document.tickertape.document.subtickertape.document.write(‘<span>’+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.backgroundColor=
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++;
}

</script>