Java Script



1- Status Bar'da tarih yazar

<script language="JavaScript">

function doClock() {

window.setTimeout( "doClock()", 1000 );

today = new Date();

self.status = today.toString();

}
doClock()
</script>

2- Her defasında farklı bir resim

<SCRIPT LANGUAGE="JavaScript">

today=new Date();
jran=today.getTime();

function rnd() {

ia=9301;
ic=49297;
im=233280;

jran = (jran*ia+ic) % im;
return jran/(im*1.0);
};

function rand(number) {

return Math.ceil(rnd()*number);
};

document.write("<CENTER>");
for(i=1;i<=1;i++) {
myNum=(rand(12));
if(myNum == 1) document.write("<img src='header1.jpg'>");
if(myNum == 2) document.write("<img src='header2.jpg'>");
if(myNum == 3) document.write("<img src='header3.jpg'>");
if(myNum == 4) document.write("<img src='header4.jpg'>");
if(myNum == 5) document.write("<img src='header1.jpg'>");
if(myNum == 6) document.write("<img src='header2.jpg'>");
if(myNum == 7) document.write("<img src='header3.jpg'>");
if(myNum == 8) document.write("<img src='header4.jpg'>");
if(myNum == 9) document.write("<img src='header1.jpg'>");
if(myNum == 10) document.write("<img src='header2.jpg'>");
if(myNum == 11) document.write("<img src='header3.jpg'>");
if(myNum == 12) document.write("<img src='header4.jpg'>");
else {
document.write();
}

};

document.write("</CENTER>");

</SCRIPT>

3- Yeni pencere açar

<FORM><input type="button" Value="Open Window" ONCLICK="window.open('http://kardanadam.cjb.net', 'Sample', 'toolbar=no,location=no,directories=yes,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=yes,width=635,height=260')"></FORM>

4- Ziyaretçinin o sayfayı kaç kere ziyaret ettiğini gösterir

<script language="JavaScript">

function getCookieVal (offset) {
var endstr = document.cookie.indexOf (";", offset);
if (endstr == -1)
endstr = document.cookie.length;
return unescape(document.cookie.substring(offset, endstr));
}
function GetCookie (name) {
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while (i < clen) {
var j = i + alen;
if (document.cookie.substring(i, j) == arg)
return getCookieVal (j);
i = document.cookie.indexOf(" ", i) + 1;
if (i == 0)
break;
}
return null;
}
function SetCookie (name, value) {
var argv = SetCookie.arguments;
var argc = SetCookie.arguments.length;
var expires = (2 < argc) ? argv[2] : null;
var path = (3 < argc) ? argv[3] : null;
var domain = (4 < argc) ? argv[4] : null;
var secure = (5 < argc) ? argv[5] : false;
document.cookie = name + "=" + escape (value) +
((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
((path == null) ? "" : ("; path=" + path)) +
((domain == null) ? "" : ("; domain=" + domain)) +
((secure == true) ? "; secure" : "");
}
function DisplayInfo() {
var expdate = new Date();
var visit;
expdate.setTime(expdate.getTime() + (24 * 60 * 60 * 1000 * 365));
if(!(visit = GetCookie("visit")))
visit = 0;
visit++;
SetCookie("visit", visit, expdate, "/", null, false);
var message;
if(visit == 1)
message=" Sayfama Hos Geldin!";
if(visit== 2)
message=" Sayfama bir daha geldigin icin tesekkür ederim !";
if(visit == 3)
message=" Ooo,yine mi sen?";
if(visit == 4)
message=" Delirmis olmalisin!";
if(visit == 5)
message=" Sen tam bir manyaksin!";
if(visit == 6)
message=" Senin bir hobiye ihtiyacin var!";
if(visit == 7)
message=" Yapacak daha iyi biseyler yok mu?";
if(visit == 8)
message=" Hiç uyumaz misin?";
if(visit == 9)
message=" Hayatin tadina baksana olm sen yaw!!!";
if(visit >= 10)
message=" Tamam tamam istedigin kadar gelebilirsin !";
alert("\n"+"Tarayiciniz bu sayfaya tam \n"
+" "+visit+"\n" +" kere ugramis. -TESEKKÜRLER-."+"\n"+"\n"
+message);
}
function ResetCounts() {
var expdate = new Date();
expdate.setTime(expdate.getTime() + (24 * 60 * 60 * 1000 * 365));
visit = 0;
SetCookie("visit", visit, expdate , "/", null, false);
history.go(0);
}

window.onload=DisplayInfo
</script>

<form>
<p align="center"><input type="button" name="update"
value="Tekrar Ziyaret Et" onclick="history.go(0)"> <input
type="button" name="reset" value="Sayaci Sifirla"
onclick="ResetCounts()"> </p>
</form>exOf (";", offset);
if (endstr == -1)
endstr = document.cookie.length;
return unescape(document.cookie.substring(offset, endstr));
}
function GetCookie (name) {
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while (i < clen) {
var j = i + alen;
if (document.cookie.substring(i, j) == arg)
return getCookieVal (j);
i = document.cookie.indexOf(" ", i) + 1;
if (i == 0)
break;
}
return null;
}
function SetCookie (name, value) {
var argv = SetCookie.arguments;
var argc = SetCookie.arguments.length;
var expires = (2 < argc) ? argv[2] : null;
var path = (3 < argc) ? argv[3] : null;
var domain = (4 < argc) ? argv[4] : null;
var secure = (5 < argc) ? argv[5] : false;
document.cookie = name + "=" + escape (value) +
((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
((path == null) ? "" : ("; path=" + path)) +
((domain == null) ? "" : ("; domain=" + domain)) +
((secure == true) ? "; secure" : "");
}
function DisplayInfo() {
var expdate = new Date();
var visit;
expdate.setTime(expdate.getTime() + (24 * 60 * 60 * 1000 * 365));
if(!(visit = GetCookie("visit")))
visit = 0;
visit++;
SetCookie("visit", visit, expdate, "/", null, false);
var message;
if(visit == 1)
message=" Sayfama Hos Geldin!";
if(visit== 2)
message=" Sayfama bir daha geldigin icin tesekkür ederim !";
if(visit == 3)
message=" Ooo,yine mi sen?";
if(visit == 4)
message=" Delirmis olmalisin!";
if(visit == 5)
message=" Sen tam bir manyaksin!";
if(visit == 6)
message=" Senin bir hobiye ihtiyacin var!";
if(visit == 7)
message=" Yapacak daha iyi biseyler yok mu?";
if(visit == 8)
message=" Hiç uyumaz misin?";
if(visit == 9)
message=" Hayatin tadina baksana olm sen yaw!!!";
if(visit >= 10)
message=" Tamam tamam istedigin kadar gelebilirsin !";
alert("\n"+"Tarayiciniz bu sayfaya tam \n"
+" "+visit+"\n" +" kere ugramis. -TESEKKÜRLER-."+"\n"+"\n"
+message);
}
function ResetCounts() {
var expdate = new Date();
expdate.setTime(expdate.getTime() + (24 * 60 * 60 * 1000 * 365));
visit = 0;
SetCookie("visit", visit, expdate , "/", null, false);
history.go(0);
}

window.onload=DisplayInfo
</script>

<form>
<p align="center"><input type="button" name="update"
value="Tekrar Ziyaret Et" onclick="history.go(0)"> <input
type="button" name="reset" value="Sayaci Sifirla"
onclick="ResetCounts()"> </p>
</form>


5- Girişi onaylama

<SCRIPT LANGUAGE="JavaScript">

<!-- Beginning of JavaScript Applet<-- begin to hide script contents from old browsers.
function Info()
{if (!confirm("Şu anda şahane bir sayfaya giriyorsunuz. Kabul mu?"))
history.go(0);return " "}
document.writeln(Info())<!--End-->

</SCRIPT>

6- Bu Script sabah yazılarınızın siyah, background'un beyaz, akşamda tam tersi olmasını sağlar

<SCRIPT LANGUAGE="JavaScript">


now = new Date();

if ((now.getHours() > 5) && (now.getHours() < 18))
{
document.bgColor='white'

document.fgColor='black'

document.linkColor='red'
}
else
{
document.bgColor='black'

document.fgColor='white'

document.linkColor='red'
}


</SCRIPT>

7- Mouse'u üzerine getirdiğinizde ekrana bir uyarı gelir

Sakın mouse'unuzu <a href="" onmouseover="alert('Nayır. Naaptın?!')">buraya</a> veya <a href="" onmouseover="alert('Sana yapmaman gerektiğini söylemiştim!')">buraya</a> yada <a href="" onmouseover="alert('Sen hiç aile terbiyesi almadın mı???')">buraya</a> getirmeyin.

8- Ziyaretçiyi selamlar

<script language="JavaScript">

alert("İyi Gezintiler ve uğradığınız için teşekkurler");

</script>

9- Saate göre hitap

<script language="javascript">
<!--
function tarih()
{
var gun=new Date();
var gunler=new Array("Pazar","Pazartesi","Salı","Çarşamba", "Perşembe","Cuma","Cumartesi");
var aylar=new Array("Ocak","Şubat","Mart","Nisan","Mayıs","Haziran", "Temmuz","Ağustos","Eylül","Ekim","Kasım","Aralık");
bugun=gun.getDate()+' '+aylar[gun.getMonth()]+' '+gun.getYear()+' '+gunler[gun.getDay()];
return bugun;
}

function zaman()
{
var saat=new Date();
var durum=new Array("Günaydın kahvaltını yapta gel.!","İyi Günler işin gücün yokmu lan senin herkes çalışıyo sen burda oturmuş internete bağlanıyon.!","oooh keyfin gıcır kahvede istermisin.!", "uyku tutmadı herhalde bu saat te ne arıyon lan internette.!");
var i=1;
if (saat.getHours()>=6 && saat.getHours()<10)
{
i=0;
}
if (saat.getHours()>=17 && saat.getHours()<22)
{
i=2;
}
if ((saat.getHours()>=22)||(saat.getHours()<6))
{
i=3;
}
hitap=durum[i];
return hitap;
}
document.write(zaman()+" "+tarih());
-->
</script>

10- Çerçeve İçinde Kayan Yazı

<!-- This is your typical scrolling banner -->
<script language="JavaScript">
// Modified by CoffeeCup Software

var id,pause=0,position=0,revol=9;

function banner()
{
var i,k;
var msg=" www.yasinevrenkaya.net ";
var speed=10;
document.thisform.thisbanner.value=msg.substring(position,position+50);

if(position++==msg.length)
{
if (revol-- < 2) return;
position=0;
}

id=setTimeout("banner()",1000/speed);
}

</script>

</head>
<body bgcolor="ffffff" onload="banner()">
<CENTER><form name="thisform">

<input type="text" name="thisbanner" size="40">
</FORM>
</CENTER>


11- Rengarenk Arka Fon

<!-- Background Changer
Just make sure you add your Title before this script.
If you change the last line in will give you the rest
of the information for your page (link color,text etc.)
Play with the colors !-->


<script>
// Modified by CoffeeCup Software

function initArray()
{
this.length = initArray.arguments.length
for (var i = 0; i < this.length; i++)
this[i+1] = initArray.arguments[i]
}

var hexChars = "0123456789ABCDEF";

function Dec2Hex (Dec)
{
var a = Dec % 16;
var b = (Dec - a)/16;
hex = "" + hexChars.charAt(b) + hexChars.charAt(a);
return hex;
}

function bgChanger (begin, end, steps)
{
steps = steps -1 ;

redA = begin.charAt(0) + begin.charAt(1);
red_valA = parseInt(redA,'16');
redB = end.charAt(0) + end.charAt(1);
red_valB = parseInt(redB,'16');
red_int = ((red_valB - red_valA) / steps) * -1;
grnA = begin.charAt(2) + begin.charAt(3);
grn_valA = parseInt(grnA,'16');
grnB = end.charAt(2) + end.charAt(3);
grn_valB = parseInt(grnB,'16');
grn_int = ((grn_valB - grn_valA) / steps) * -1;
bluA = begin.charAt(4) + begin.charAt(5);
blu_valA = parseInt(bluA,'16');
bluB = end.charAt(4) + end.charAt(5);
blu_valB = parseInt(bluB,'16');
blu_int = ((blu_valB - blu_valA) / steps) * -1;

step = 2;
red = red_valA;
grn = grn_valA;
blu = blu_valA;

document.bgColor = begin;

while ( steps >= step )
{
red -= red_int;
red_round = Math.round(red);
red_hex = Dec2Hex(red);

grn -= grn_int;
grn_round = Math.round(grn);
grn_hex = Dec2Hex(grn);

blu -= blu_int;
blu_round = Math.round(blu);
blu_hex = Dec2Hex(blu);

document.bgColor = red_hex + grn_hex + blu_hex;

step++;
}
document.bgColor = end;
}

</script>
</head>
<body bgcolor=#000000 text=#FFFFFF link="FF0000" vlink="8888FF" alink="FF00FF">
<script>
<!--
// black to black (pause)
bgChanger("000000","000000",25);
// black to red
bgChanger("000000","FF0000",25);
// red to black
bgChanger("FF0000","000000",25);
// black to purple
bgChanger("000000","AA00EE",25);
// purple to black
bgChanger("AA00EE","000000",25);
// black to blue
bgChanger("000000","0000FF",25);
// blue to black
bgChanger("0000FF","000000",25);
// black to black (pause)
bgChanger("000000","000000",25);
// -->
</script>
</head>
<body>
<BODY BGCOLOR=000000 text="#ffffff" link="#0000ff" vlink="#c00c0">

<CENTER><H2>www.uguronur.8k.com</CENTER></H2>

12- Saat


<!-- This is a clock that shows the system time -->
<SCRIPT LANGUAGE="JavaScript">

var timerID = null;
var timerRunning = false;

function stopclock ()
{
if(timerRunning)
clearTimeout(timerID);
timerRunning = false;
}

function showtime ()
{
var now = new Date();
var hours = now.getHours();
var minutes = now.getMinutes();
var seconds = now.getSeconds()

var timeValue = "" + ((hours >12) ? hours -12 :hours)
timeValue += ((minutes < 10) ? ":0" : ":") + minutes
timeValue += ((seconds < 10) ? ":0" : ":") + seconds
timeValue += (hours >= 12) ? " P.M." : " A.M."
document.clock.face.value = timeValue;

// you could replace the above with this
// and have a clock on the status bar:
// window.status = timeValue;

timerID = setTimeout("showtime()",1000);
timerRunning = true;
}

function startclock ()
{
// Make sure the clock is stopped
stopclock();
showtime();
}

</SCRIPT>

<BODY onLoad="startclock(); timerONE=window.setTimeout" BGCOLOR="000080" TEXT="ffffff">

<CENTER><form name="clock" onSubmit="0">
<input type="text" name="face" size=13 value=""></CENTER>

13- Internet Explorer Çubuğunda Kayan Yazı

<!-- This scrolls ' Your Message Here ' in the status bar -->
<SCRIPT LANGUAGE="JavaScript">
//Modified by Coffeecup.com

function infoscroll(seed,looped)
{
var text1 = " www.uguronur.8k.com ";
var text2 = " [email protected] ";
var msg=text1+text2;
var putout = " ";
var c = 1;

if (looped > 10)
{ window.status="<Thanks !>"; }
else if (seed > 100)
{
seed--;
var cmd="infoscroll(" + seed + "," + looped + ")";
timerTwo=window.setTimeout(cmd,100);
}
else if (seed <= 100 && seed > 0)
{
for (c=0 ; c < seed ; c++)
{ putout+=" "; }
putout+=msg.substring(0,100-seed);
seed--;
var cmd="infoscroll(" + seed + "," + looped + ")";
window.status=putout;
timerTwo=window.setTimeout(cmd,100);
}
else if (seed <= 0)
{
if (-seed < msg.length)
{
putout+=msg.substring(-seed,msg.length);
seed--;
var cmd="infoscroll(" + seed + "," + looped + ")";
window.status=putout;
timerTwo=window.setTimeout(cmd,100); // 100
}
else
{
window.status=" ";
looped += 1;
var cmd = "infoscroll(100," + looped + ")";
timerTwo=window.setTimeout(cmd,75); // 75
}
}
}
// -->

<!--
infoscroll(100,1)
// -->

</SCRIPT>


14- Çeşitli Web Sitelerine Yönlendirme

<!-- GotoBox Change the VALUES to your links! -->

<CENTER>
<FORM>

<SELECT NAME="list">
<OPTION SELECTED VALUE="http://www.arabul.com">Arabul
<OPTION VALUE="http://www.pcmagazine.com.tr">PC Magazine Online
<OPTION VALUE="http://www.microsoft.com">Microsoft
<OPTION VALUE="http://www.altavista.com">Altavista
</SELECT><P>

<INPUT TYPE=BUTTON VALUE="Bağlan"
onClick="top.location.href=this.form.list.options[this.form.list.selectedIndex].value">

</FORM>
</CENTER>



15.Arka Menü

<style>.tus {
    BACKGROUND-COLOR: #cc0000; BORDER-BOTTOM: #003060 1px solid; BORDER-LEFT: #003060 1px solid; BORDER-RIGHT: #003060 1px solid; BORDER-TOP: #003060 1px solid; COLOR: #003060; FONT-FAMILY: arial; FONT-SIZE: 11px; FONT-WEIGHT: bold
}
TABLE {
    FONT-FAMILY: arial; FONT-SIZE: 11px
}
A {
    COLOR: #ffffff; TEXT-DECORATION: none
}
A:hover {
    COLOR: #c0c0c0
}
.x {
    COLOR: #800000; TEXT-DECORATION: none
}
.x:hover {
    COLOR: #cc0000
}
BODY {
    FONT-FAMILY: arial; FONT-SIZE: 11px
}
H3 {
    COLOR: #003060
}
.skin0 {
    BACKGROUND-COLOR: menu; BORDER-BOTTOM: black 2px solid; BORDER-LEFT: black 2px solid; BORDER-RIGHT: black 2px solid; BORDER-TOP: black 2px solid; CURSOR: default; FONT-FAMILY: Verdana; LINE-HEIGHT: 20px; POSITION: absolute; VISIBILITY: hidden; WIDTH: 200px
}
.skin1 {
    BACKGROUND-COLOR: menu; BORDER-BOTTOM: buttonhighlight 2px outset; BORDER-LEFT: buttonhighlight 2px outset; BORDER-RIGHT: buttonhighlight 2px outset; BORDER-TOP: buttonhighlight 2px outset; CURSOR: default; POSITION: absolute; VISIBILITY: hidden; WIDTH: 165px
}
.menuitems {
    PADDING-LEFT: 15px; PADDING-RIGHT: 10px
}
</style>
</head>

<body bgColor="#FFFFFF" bgProperties="fixed" leftMargin="0"
onmouseover="window.status=' Oflular.com - Global Bir Site.. ';return true" topMargin="10">
<script language="JavaScript1.2">
var menuskin=1

var display_url=0


function showmenuie5(){
var rightedge=document.body.clientWidth-event.clientX
var bottomedge=document.body.clientHeight-event.clientY

if (rightedge<ie5menu.offsetWidth)
ie5menu.style.left=document.body.scrollLeft+event.clientX-ie5menu.offsetWidth
else
ie5menu.style.left=document.body.scrollLeft+event.clientX

if (bottomedge<ie5menu.offsetHeight)
ie5menu.style.top=document.body.scrollTop+event.clientY-ie5menu.offsetHeight
else
ie5menu.style.top=document.body.scrollTop+event.clientY

ie5menu.style.visibility="visible"
return false
}

function hidemenuie5(){
ie5menu.style.visibility="hidden"
}

function highlightie5(){
if (event.srcElement.className=="menuitems"){
event.srcElement.style.backgroundColor="highlight"
event.srcElement.style.color="white"
if (display_url==1)
window.status=event.srcElement.url
}
}

function lowlightie5(){
if (event.srcElement.className=="menuitems"){
event.srcElement.style.backgroundColor=""
event.srcElement.style.color="black"
window.status=''
}
}

function jumptoie5(){
if (event.srcElement.className=="menuitems"){
if (event.srcElement.getAttribute("target")!=null)
window.open(event.srcElement.url,event.srcElement.getAttribute("target"))
else
window.location=event.srcElement.url
}
}
</script>
<!--[if IE]>
<DIV class=skin0 id=ie5menu onclick=jumptoie5() onmouseout=lowlightie5()
onmouseover=highlightie5()>
<DIV class=menuitems url="deneme/">ara mara</DIV>
<DIV class=menuitems url="deneme/">Yeni Kayıt</DIV>
<DIV class=menuitems url="deneme/">Sizden Gelenler</DIV>
<HR>

<DIV class=menuitems url="deneme/">yaw yaz bişi</DIV>
<DIV class=menuitems url="deneme/">Reklam Vermek İçin</DIV>
<HR>

<DIV class=menuitems url="deneme/">benbene</DIV>
<DIV class=menuitems url="deneme/">selam</DIV>
<DIV class=menuitems url="deneme/">aleyküm selam</DIV>
<HR>

<DIV class=menuitems url="deneme/">SUR Cumhuriyeti</DIV>
<DIV class=menuitems url="deneme">SUR Fotoğrafları</DIV>
<DIV class=menuitems url="deneme/">SUR ' un Tarihi</DIV>
<DIV class=menuitems url="deneme/">Nöbetçi SUR lar</DIV>
<DIV class=menuitems url="deneme/">Otobüs Saatleri</DIV>
<DIV class=menuitems url="deneme/">Önemli Telefonlar</DIV>
<HR>

<DIV class=menuitems url="mailto:[email protected]">bahadıra e maaall</DIV></DIV><![endif]-->
<script language="JavaScript1.2">
if (document.all&&window.print){
if (menuskin==0)
ie5menu.className="skin0"
else
ie5menu.className="skin1"
document.oncontextmenu=showmenuie5
document.body.onclick=hidemenuie5
}
</script>