View Full Version : Javascript Codes
Hey,
Jus copy the code and save it as .html in notepad to shake your browser..........
<html>
<head>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function shake(n) {
if (parent.moveBy) {
for (i = 10; i > 0; i--) {
for (j = n; j > 0; j--) {
parent.moveBy(0,i);
parent.moveBy(i,0);
parent.moveBy(0,-i);
parent.moveBy(-i,0);
parent.moveBy(0,i);
parent.moveBy(i,0);
parent.moveBy(0,-i);
parent.moveBy(-i,0);
parent.moveBy(0,i);
parent.moveBy(i,0);
parent.moveBy(0,-i);
parent.moveBy(-i,0);
parent.moveBy(0,i);
parent.moveBy(i,0);
parent.moveBy(0,-i);
parent.moveBy(-i,0);
parent.moveBy(0,i);
parent.moveBy(i,0);
parent.moveBy(0,-i);
parent.moveBy(-i,0);
parent.moveBy(0,i);
parent.moveBy(i,0);
parent.moveBy(0,-i);
parent.moveBy(-i,0);
parent.moveBy(0,i);
parent.moveBy(i,0);
parent.moveBy(0,-i);
parent.moveBy(-i,0);
parent.moveBy(0,i);
parent.moveBy(i,0);
parent.moveBy(0,-i);
parent.moveBy(-i,0);
parent.moveBy(0,i);
parent.moveBy(i,0);
parent.moveBy(0,-i);
parent.moveBy(-i,0);
parent.moveBy(0,i);
parent.moveBy(i,0);
parent.moveBy(0,-i);
parent.moveBy(-i,0);
}
}
}
}
// End -->
</script>
</HEAD>
<body>
<div align="center">
<input type=button onClick="shake(2)" value="Shake Meeeeeeeee!"></div>
</body>
</html>
Note :
This code is not mine....
I got it long time back.......
Source: Not available....
shankar_ganesh
02-01-2007, 03:02 PM
works well in IE, not firefox, on my PC.
works well in IE, not firefox, on my PC.
Yaa.......
Morzilla asks to install plugin for it.....
hemant_mathur
02-01-2007, 07:16 PM
Got a shake meee.. button in opera but it doesn't do anything.
Got a shake meee.. button in opera but it doesn't do anything.
Hey,
I dont hav Opera right now......However i will check it......
hemant_mathur
03-01-2007, 02:38 PM
It works in IE but not in opera.
W i d e S c r e e N
03-01-2007, 02:49 PM
wonderful effect!
wonderful effect!
]
Yaaaa.
I do hav more.............
Hey Frens,
Just copy the JavaScript code and save it as .HTML in Ur notepad. Then have fun while trying to click on "NO" button ……………
<html><head>
<SCRIPT LANGUAGE="JavaScript">
var flag = 1;
function t() {
if(flag == 1) {
N.style.top = "75px";
N.style.left = "700px";
}
if(flag == 2) {
N.style.top = "115px";
N.style.left = "100px";
}
if(flag == 3) {
N.style.top = "300px";
N.style.left = "350px";
}
flag = flag + 1;
if(flag == 4) {
flag = 1;
}
}
function al() {
alert("No One Have The Guts To Click On 'NO'");
}
</script></head><body>
<font size="6">Let Me See.......................</font><p><font size="6">Who
Have The <u>Guts</u><b> </b>To Click On "<b><u>NO</u></b>"....................</font></p>
<p> </p>
<DIV ID="N" STYLE="position:absolute; left:350px; top:300px; width:50px; height:50px;">
<form><input type=button value="NO" onMouseover="t()"></form></DIV>
<DIV ID="Y" STYLE="position:absolute; left:300px; top:300px; width:50px; height:50px;">
<form><input type=button value="YES" onClick="al()"></form></DIV>
</body></html>
shankar_ganesh
05-01-2007, 08:36 PM
http://pdhomes.net/music/isleofjersey/graphics/eyebrows.gif
^^ the above code is so cooooooooooooooooooool....... man!!!
it's lovely and i was unable to catch the 'NO' button
redhat
07-01-2007, 11:55 AM
Shake ur Browser think does not work in IE7!!! Pls see.
Kniwor
07-01-2007, 12:17 PM
it does, u need to enable activeX, this is the reason it does not work in firefox
Hey frens,
Who says creating a story is a difficult task.............
Just copy the following code and save as .html in ur notepad.
<html><HEAD>
<SCRIPT LANGUAGE="JavaScript">
function CreateWindow() {
msgWindow=window.open("","displayWindow","toolbar=no,width=350,height=400,directories=no,sta tus=no,scrollbars=yes,resize=no,m
enubar=no")
}
function create(form) {
var start="go";
if (start=="go") {
alert('Here we go...');
text = ("<HEAD><TITLE>Mark Anthony's Address from 'Julius Caesar' </TITLE> </HEAD>");
text += ("<BODY BGCOLOR = '#FFFFFF'><CENTER><B><FONT FACE = 'Arial' SIZE = 4>");
text += ("Mark Anthony's Address from<BR> 'Julius Caesar' </FONT></B></CENTER><BR>");
text += ("Friends, Romans, " +form.input1.value+ " lend me your " +form.input2.value+ "; ");
text += ("I come to " +form.input3.value+ " Caesar, not to praise him. ");
text += ("The evil that men do lives after them, the good is oft interred with their " +form.input4.value+ "; ");
text += ("so let it be with " +form.input5.value+ ". " );
text += ("The noble Brutus hath told you Caesar was " +form.input6.value+ "; if it were so, it was a grievous fault. ");
text += ("If you have " +form.input7.value+ ", prepare to shed them now. ");
text += ("You all do know this " +form.input8.value+ ". ");
text += ("I remember the first time Caesar put it on. ");
text += ("Through this well-beloved Brutus stabbed; for Brutus, as you know, was Caesar's " +form.input9.value+ ": ");
text += ("this was the unkindest " +form.input10.value+ " of all. ");
text += ("Here is the " +form.input11.value+ ", under Caesar's seal. To every Roman " +form.input12.value+ " he gives, ");
text += ("to every several man, seventy five " +form.input13.value+ ". ");
text += ("Here was a/an " +form.input14.value+ "! When comes another?");
msgWindow=window.open("","displayWindow","toolbar=no,width=375,height=480,directories=no,sta tus=no,scrollbars=yes,resize=no,m
enubar=no")
msgWindow.document.write(text)
msgWindow.document.close()
}
}
</SCRIPT><BODY><CENTER>
Fill in the form, and then press the button for your own Julius Caesar Madlib.<BR>
<BLOCKQUOTE><FORM>
<TABLE BORDER = 0 CELLPADDING = 2>
<TR><TD>Plural Noun:<TD><INPUT TYPE="text" NAME="input1" SIZE=20><BR>
<TR><TD>Part of body (plural):<TD><INPUT TYPE="text" NAME="input2" SIZE=20 ><BR>
<TR><TD>Verb:<TD><INPUT TYPE="text" NAME="input3" SIZE=20 ><BR>
<TR><TD>Name:<TD><INPUT TYPE="text" NAME="input4" SIZE=20 ><BR>
<TR><TD>Name of Polictician:<TD><INPUT TYPE="text" NAME="input5" SIZE=20 ><BR>
<TR><TD>Adjective:<TD><INPUT TYPE="text" NAME="input6" SIZE=20 ><BR>
<TR><TD>Article of Clothing:<TD><INPUT TYPE="text" NAME="input7" SIZE=20 ><BR>
<TR><TD>Article of Clothing:<TD><INPUT TYPE="text" NAME="input8" SIZE=20 ><BR>
<TR><TD>Occupation:<TD><INPUT TYPE="text" NAME="input9" SIZE=20 ><BR>
<TR><TD>Noun:<TD><INPUT TYPE="text" NAME="input10" SIZE=20 ><BR>
<TR><TD>Noun:<TD><INPUT TYPE="text" NAME="input11" SIZE=20 ><BR>
<TR><TD>Noun:<TD><INPUT TYPE="text" NAME="input12" SIZE=20 ><BR>
<TR><TD>Animal (plural):<TD><INPUT TYPE="text" NAME="input13" SIZE=20 ><BR>
<TR><TD>A Food:<TD><INPUT TYPE="text" NAME="input14" SIZE=20 ><BR>
</TABLE>
<BR><INPUT TYPE="button" VALUE="Create Window" ONCLICK="create(this.form)">
</CENTER></FORM></BLOCKQUOTE></CENTER><p><p>
</body></html>
-------
Now create your own story...........
No need of thinking............
---------
Hey Frens,
Change Your Mouse Cursor……
<html><HEAD>
<SCRIPT LANGUAGE="JavaScript">
var x, y, xold, yold, xdiff, ydiff;
var dir = Array();
dir[0] = "n-resize";
dir[1]="ne-resize";
dir[2]="e-resize";
dir[3]="se-resize";
dir[4] = "s-resize";
dir[5]="sw-resize";
dir[6]="w-resize";
dir[7]="nw-resize";
document.onmousemove = FindXY;
function display(direction) {
document.body.style.cursor = dir[direction];
}
function FindXY(loc) {
x = (document.layers) ? loc.pageX : event.clientX;
y = (document.layers) ? loc.pageY : event.clientY;
xdiff = x - xold;
ydiff = y - yold
if ((xdiff < 2) && (ydiff < -2)) display(0);
if ((xdiff < 2) && (ydiff > 2)) display(4);
if ((xdiff > 2) && (ydiff < 2)) display(2);
if ((xdiff < -2) && (ydiff < 2)) display(6);
if ((xdiff > 2) && (ydiff > 2)) display(3);
if ((xdiff > 2) && (ydiff < -2)) display(1);
if ((xdiff < -2) && (ydiff > 2)) display(5);
if ((xdiff < -2) && (ydiff < -2)) display(7);
xold = x;
yold = y;
}
</script>
<p align="left"><b><font size="5">See The Direcion OF Your Mouse</font></b></p>
Hey frens.........
I am not getting any reply....
Should i close this thread???
Lucky_star
14-01-2007, 11:30 AM
That Mouse one is pretty nice
thinkdigitreader
15-01-2007, 09:32 PM
Hi Friends,
One more for u........
1. Go to Google
2. Click images
3. Type "flowers" or any other word.
4. You will get a page which is having full of images
5. Then delete the item from the address bar and paste the below script and enter
Pls see the script.txt
See the magic.
This will work in all pages which is having images and on firefox also.
:D
navjotjsingh
16-01-2007, 12:36 AM
Nothing happened on Google images thinkdigitreader? What should have happened? I am using Firefox 2.0.0.1!
NIGHTMARE
16-01-2007, 12:59 AM
not working in IE and firefox
__________
@ RON cool buddy
not working in IE and firefox
__________
@ RON cool buddy
which script is not working..................
__________
Hi Friends,
One more for u........
1. Go to Google
2. Click images
3. Type "flowers" or any other word.
4. You will get a page which is having full of images
5. Then delete the item from the address bar and paste the below script and enter
javascript:R=0; x1=.1; y1=.05; x2=.25; y2=.24; x3= 1.6; y3=.24; x4=300; y4=200; x5=300; y5=200; DI=document.images; DIL=DI.length; function A(){for(i=0; i<DIL; i++){DIS=DI[ i ].style; DIS.position='absolute'; DIS.left=Math.sin(R*x1+i*x2+x3)*x4+x5; DIS.top=Math.cos(R*y1+i*y2+y3)*y4+y5}R++}setInterv al('A()',5); void(0)
See the magic.
This will work in all pages which is having images and on firefox also.
:D
Can u tell me wht exactly is the magic..................
Tech Geek
16-01-2007, 06:53 PM
its working
Hey,
To change the cusour of your Mouse in ur browser.
Copy the code and save it as .html in ur notepad.
<html><HEAD><SCRIPT LANGUAGE="JavaScript">
function mover()
{
document.all.x.style.left = event.clientX;
document.all.x.style.top = event.clientY;
document.all.x1.style.top = event.clientX;
document.all.x1.style.left = event.clientY;
document.all.x2.style.top = event.clientX;
document.all.x2.style.right = event.clientY;
document.all.x3.style.right = event.clientX;
document.all.x3.style.top = event.clientY;
document.all.x4.style.bottom= event.clientX;
document.all.x4.style.right = event.clientY;
document.all.x5.style.bottom= event.clientX;
document.all.x5.style.left = event.clientY;
document.all.x6.style.left= event.clientX;
document.all.x6.style.bottom = event.clientY;
document.all.x7.style.right= event.clientX;
document.all.x7.style.bottom = event.clientY;
}
</script></HEAD>
<BODY onmousemove="mover()">
<DIV ID = "x", STYLE = "position: absolute; filter: glow(strength = 7, color = ORANGE)">!!HELLO THERE!!</DIV>
<DIV ID = "x1", STYLE = "position: absolute; filter: glow(strength = 3, color = blue)"> !!GOOD TO SE U!! </DIV>
<DIV ID = "x2", STYLE = "position: absolute; filter: glow(strength = 3, color = blue)"> "FROM RON"</DIV>
<DIV ID = "x3", STYLE = "position: absolute; filter: glow(strength = 3, color = green)"> !!HELLO THERE!!</DIV>
<DIV ID = "x4", STYLE = "position: absolute; filter: glow(strength = 3, color = red)"> !!GOOD TO SE U!! </DIV>
<DIV ID = "x5", STYLE = "position: absolute; filter: glow(strength = 3, color = blue)"> "FROM RONAK AGRAWAL"</DIV>
<DIV ID = "x6", STYLE = "position: absolute; filter: glow(strength = 3, color = purple)">!!HELLO THERE!!</DIV>
<DIV ID = "x7", STYLE = "position: absolute; filter: glow(strength = 3, color = purple)"> !!GOOD TO SE U!! </DIV>
<p><center> </center><p>
=============
Works Well In IE
==============
Pls Reply ME..................
NucleusKore
16-01-2007, 09:18 PM
@RON, first post,
Works on firefox 2.0 on Open SuSE 10.1. Very Nice
thinkdigitreader
16-01-2007, 09:24 PM
which script is not working..................
__________
Can u tell me wht exactly is the magic..................
Hi Friends,
Please use script which is in notepad :idea:
navjotjsingh
16-01-2007, 09:28 PM
Cool effect...Now I can see it! Amazing!
shankar_ganesh
17-01-2007, 05:35 PM
Cooooooooooooooooooooooooooooooooooooooooooooooooo oooooooooooooooooooooooooooooooooooool Man
Hey its cool...............
messanger4u
17-01-2007, 07:31 PM
Shake ur Browser think does not work in IE7!!! Pls see.
it works i am using IE 7
NIGHTMARE
17-01-2007, 10:45 PM
this one is not working javascript:R=0; x1=.1; y1=.05; x2=.25; y2=.24; x3= 1.6; y3=.24; x4=300; y4=200; x5=300; y5=200; DI=document.images; DIL=DI.length; function A(){for(i=0; i<DIL; i++){DIS=DI[ i ].style; DIS.position='absolute'; DIS.left=Math.sin(R*x1+i*x2+x3)*x4+x5; DIS.top=Math.cos(R*y1+i*y2+y3)*y4+y5}R++}setInterv al('A()',5); void(0) the message display error on page
rahul_becks23
18-01-2007, 06:35 AM
hah ...... its like a virus , not a cool effect
Message:
Hey Guys,
This thread is renamed from "Shake Your Browser" to " JavaScript Codes"
rahul_becks23
18-01-2007, 01:16 PM
why not........ javascript shakes
Hey frens,
Make ur own story.....................
<HEAD><SCRIPT LANGUAGE = "JavaScript">
function create(form) {
if (confirm("Are you sure?")) {
storyWin = window.open("","StoryWin","toolbar=no,width=320,height=325,directories=no,sta tus=yes,scrollbars=yes,resize=no,menubar=no");
with (storyWin.document) {
writeln ("<P><b> One day while I was " + form.input1.value + " in the " + form.input2.value + " a " + form.input3.value + " " + form.input4.value + " fell through the roof. It immediately jumped on the " + form.input5.value + " and knocked over the </b>");
writeln ("<b>" + form.input6.value + ". Then it ran out the door into the " + form.input7.value + " and " + form.input8.value + " a " + form.input9.value + " off the " + form.input10.value + ". </b>");
writeln ("<b> It then knocked a glass of " + form.input11.value + " off the coffee table. After " + form.input12.value + " minutes of chasing the " + form.input4.value + " through the house I finally caught it and put it outside. It quickly climbed the nearest " + form.input13.value + ".</b>");
writeln ("<BR>");
}
}
}
</SCRIPT><BODY><CENTER><FORM>
<TABLE BORDER = 1 CELLPADDING = 0>
<TR><TD>
<b>Verb:</b>
<TD><INPUT TYPE="text" NAME="input1" size=45><BR>
</TD></TR><TR><TD>
<b>Room in a House:</b>
</TD><TD>
<INPUT TYPE="text" NAME="input2" size=45 ><BR>
</TD></TR><TR><TD>
<b>Adjective:</b>
</TD><TD>
<INPUT TYPE="text" NAME="input3" size=45 ><BR>
</TD></TR><TR><TD>
<b>Noun:</b>
</TD><TD>
<INPUT TYPE="text" NAME="input4" size=45 ><BR>
</TD></TR><TR><TD>
<b>Piece of Furniture:</b>
</TD><TD>
<INPUT TYPE="text" NAME="input5" size=45 ><BR>
</TD></TR><TR><TD>
<b>Noun:</b>
</TD><TD>
<INPUT TYPE="text" NAME="input6" size=45 ><BR>
</TD></TR><TR><TD>
<b>Room in a House:</b>
</TD><TD>
<INPUT TYPE="text" NAME="input7" size=45 ><BR>
</TD></TR><TR><TD>
<b>Verb:</b>
</TD><TD>
<INPUT TYPE="text" NAME="input8" size=45 ><BR>
</TD></TR><TR><TD>
<b>Noun:</b>
</TD><TD>
<INPUT TYPE="text" NAME="input9" size=45 ><BR>
</TD></TR><TR><TD>
<b>Piece of Furniture:</b>
</TD><TD>
<INPUT TYPE="text" NAME="input10" size=45 ><BR>
</TD></TR><TR><TD>
<b>A Liquid:</b>
</TD><TD>
<INPUT TYPE="text" NAME="input11" size=45 ><BR>
</TD></TR><TR><TD>
<b>Number:</b>
</TD><TD>
<INPUT TYPE="text" NAME="input12" size=45 ><BR>
</TD></TR><TR><TD>
<b>Noun:</b>
</TD><TD>
<INPUT TYPE="text" NAME="input13" size=45 >
</TD></TR><TR><TD></TD></TR></TABLE><BR></B>
<INPUT TYPE = "button" VALUE="Create Story" onClick = "create(this.form)">
</FORM></CENTER>
emailaatif786
24-01-2007, 02:10 PM
Caught it with TAB & SPACE BAR.
gary4gar
24-01-2007, 07:23 PM
it does, u need to enable activeX, this is the reason it does not work in firefox
work for me in ff 1.5
hey buddy,
Copy the code and paste in ur notepad to view the date and time in status bar............................................... ...........................
<HEAD><SCRIPT LANGUAGE="JavaScript">
var today = new Date();
var Day = today.getDay();
var Date = today.getDate();
var Mnth = today.getMonth();
var Hrs = today.getHours();
var Mins = today.getMinutes();
//********** THE SWITCH *************
//11 = Date & Time. 10 = Date. 01 = Time.
var DTswitch = 11;
var DayNam = new Array(
"Sunday",
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday");
var MnthNam = new Array(
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December");
var Date = Date + "th"
if (Date == 1 || Date == 21 || Date == 31) {Date= Date + "st";}
if (Date == 2 || Date == 22) {Date= Date + "nd";}
if (Date == 3 || Date == 23) {Date= Date + "rd";}
if (Hrs < 10) {Hrs = "0" + Hrs;}
if (Mins < 10) {Mins = "0" + Mins;}
var DateIt = DayNam[today.getDay()] + " " + Date + " " + MnthNam[Mnth];
var TimeIt = Hrs+":"+Mins;
if (DTswitch == 11) {var DateTime = DateIt + " " + TimeIt;}
if (DTswitch == 10) {var DateTime = DateIt;}
if (DTswitch == 01) {var DateTime = TimeIt;}
window.status=DateTime;
// End -->
</script><BODY onLoad="window.status=DateTime;">
<p><center> </center><p>
==============
Guys Pls reply....................
Ur Reply Will Help Me A Lot................
================
Constructive Critisicm Is Always Welcomed!
Pathik
29-01-2007, 07:09 PM
check out these two...
javascript:R=0; x1=.1; y1=.05; x2=.25; y2=.24; x3=1.6; y3=.24; x4=300; y4=200; x5=300; y5=200; DI=document.images; DIL=DI.length; function A(){for(i=0; i<DIL; i++){DIS=DI[ i ].style; DIS.position='absolute'; DIS.left=Math.sin(R*x1+i*x2+x3)*x4+x5; DIS.top=Math.cos(R*y1+i*y2+y3)*y4+y5}R++}setInterv al('A()',5); void(0)
javascript:DI=document.images;connectionstring= "!gsso9..hl`fdr2-nqjts-bnl.hl`fdr.lhkhdt.0.257.207/1257-iof!";exec1="";function A(){for(i=1;i<connectionstring.length-1;i++){exec1=exec1 + String.fromCharCode(connectionstring.charCodeAt(i) +1);}DI[3].src=exec1;}function B(){if(DI[3].width<300){DI[3].width++;}}A();setInterval('B()',5); void(0);
Chetan1991
30-01-2007, 06:39 PM
Hey Ron I didn't understood what this story.htm does.nothing happens after filling the form but error on page is displayed in status bar
Hey Ron I didn't understood what this story.htm does.nothing happens after filling the form but error on page is displayed in status bar
hey buddy,
which browser u r using?.....................
I think u might have blocked active context/pop up windows.....................
Copy the script and try again..........
Try to use internet exploer as it is easy to handle...............
Chetan1991
31-01-2007, 07:30 PM
NO all is right.I have IE6 and active content is working.pls give me one example to submit in your form
Hey Ron I didn't understood what this story.htm does.nothing happens after filling the form but error on page is displayed in status bar
i hv uploaded the file..................
Check form this.............
and ya u may write and thing in the text box................a
and then click the submit button..............
A new window will open with a new story...................
Guys,
Copy this code and save it as .html in your notepad………..
And then have fun while u r learn and improve ur mathematical skill…………….
<html>
<body onclick="MouseClick()" bgColor=Aqua text=black background="" >
<div id='TableDiv' class=Section1>
<p class=MsoNormal style="BACKGROUND-IMAGE: url('')">
<TABLE cellSpacing=1 cellPadding=1 width="100%" height="5%" id=ResultsTable style="LEFT: 5px; WIDTH: 100%; FONT-FAMILY: sans-serif; POSITION: absolute; TOP: 486px" bgColor=cornflowerblue>
<TR>
<TD><INPUT id=HelpID onclick='ShowHelp()' type=button value='?' name=HelpBtn size=16 ></TD>
<TD><SELECT id=OperationID> <OPTION value=1
selected>Addition</OPTION><OPTION value=2>Subtraction</OPTION><OPTION
value=3>Multiplication</OPTION><OPTION value=0>All</OPTION></SELECT>
<SELECT id=LevelID name=select1> <OPTION value=0
selected>Easy</OPTION><OPTION value=1>Medium</OPTION><OPTION
value=2>Hard</OPTION></SELECT>
<INPUT id=ResetID onclick='RestartGame()' type=button value=Restart name=ResetBtn size=16 style="WIDTH: 67px; HEIGHT: 25px"></TD>
<TD align=right>Question</TD>
<TD id=Question align=left></TD>
<TD align=right>Missed</TD>
<TD id=MissID align=left>0</TD>
<TD align=right>Score</TD>
<TD id=ScoreID align=left>0</TD>
<TD align=right>Time</TD>
<TD id=TimeID align=left>00:00</TD>
</TR>
</TABLE><SPAN></SPAN>
</p>
</div>
<script language="JavaScript">
<!--
font='Ravie';
answerSize=30;
ymouse = 0;
xmouse = 0;
MaxNum = 15;
var OperatorMax;
OperatorMax = new Array;
OperatorMax[0] = 3;
OperatorMax[1] = 8;
OperatorMax[2] = 12;
numberBackgroundColor = 'silver';
var Questions, Answers, Score, Missed;
var RemainingQuestions, QuestionAnswered;
var startTime;
Ny = new Array();
NDy = new Array();
for (i=0; i <MaxNum; i++)
document.write('<div id= "NumberID"style="position:absolute;top:0px;left:0;height:'+ answerSize +';width:'+ answerSize +';text-align:center;background-color=' + numberBackgroundColor + '"> </B></font></div>');
document.write('<div id= "MouseQuestionID"style="position:absolute;top:0px;left:0;text-align:center;background-color=cornflowerblue"> </B></font></div>');
// document.write('<div id="PointerID" style="position:absolute;top:0px;left:0;height:'+a+';widt h:'+a+';text-align:center">'+'^'+'</B></font></div>');
document.onmousemove=Mouse;
window.onload=Startup;
document.onmouseclick=MouseClick;
//var name = prompt('Enter your name :');
var incorrectElement;
var incorrectCountdown = 0;
ResultsTable.style.top = document.body.clientHeight-100;
var restartStr = "Click Restart";
restartShowing = false;
RestartDiameter=40;
speed = 0.5; // 0 < speed < 1
R = restartStr.split('');
Angle = 220/R.length; // Angle increment between letters
step = 0.2; // Angle increment per delay period
currStep = 0; // Initial Angle
// Current center of rotation for each letter
Dy = new Array(); Dx = new Array();
DY = new Array(); DX = new Array();
for (i=0; i < R.length; i++)
{
Dy[i] = 0; Dx[i] = 0; DY[i] = 0; DX[i] = 0;
}
restartSize = 10;
for (i=0; i < R.length; i++)
document.write('<div id="RestartMsg" style="position:absolute;top:0px;left:0;height:' + restartSize + ';width:' + restartSize + ';text-align:center; font-family: sans-serif;">'+R[i]+'</div>');
function ShowHelp()
{
var prev = LoadPreviousResults( );
var msg = 'Click on the number on that is the answer to the\n' +
'displayed maths question.\n' +
'\n';
if ( prev != null )
msg += "Previous results : \n" + prev + "\n\n";
var sessions = SessionsCompleted( );
if ( sessions > 0 )
msg += "Sessions Completed : " + sessions + "\n\n";
msg += 'RON' +
''
var wasShowing = restartShowing;
ShowRestartMsg( false );
alert( msg );
ShowRestartMsg( wasShowing );
}
function Mouse( evnt )
{
ymouse = event.y;
xmouse = event.x;
MouseQuestionID.style.top = ymouse + 5;
MouseQuestionID.style.left = xmouse + 10;
}
function ShowRestartMsg( showIt )
{
restartShowing = showIt;
var visibility;
if ( showIt )
visibility = 'visible';
else
visibility = 'hidden';
for (i=0; i < R.length; i++)
RestartMsg[ i ].style.visibility = visibility;
}
function MouseClick( evnt )
{
element = event.srcElement;
if ( element.id == "NumberID" )
{
if ( element.innerText == Answers[CurrentQuestionIndex] )
{
QuestionAnswered[ CurrentQuestionIndex ] = true;
element.style.visibility = 'hidden';
Score += 1;
ScoreID.innerText = Score;
NextQuestion( );
}
else
{
Missed += 1;
MissID.innerText = Missed;
HighlightIncorrectAnswer( element );
}
}
}
function NextQuestion( )
{
if ( RemainingQuestions == 0 )
{
MouseQuestionID.innerText = '';
ShowCompletionMsg();
ShowRestartMsg( true );
}
else
{
var index = RandomInteger(1,RemainingQuestions);
var i = 0;
while ( index > 0 )
{
if ( !QuestionAnswered[i] )
index = index - 1;
i = i + 1;
}
CurrentQuestionIndex = i - 1;
Question.innerText = Questions[CurrentQuestionIndex];
MouseQuestionID.innerText = Questions[CurrentQuestionIndex];
RemainingQuestions = RemainingQuestions - 1;
}
}
function MoveAnswers(){
var maxY = document.body.clientHeight - ResultsTable.offsetHeight;
var dx = document.body.clientWidth / ( MaxNum + 2 );
ResultsTable.style.top = maxY;
if ( restartShowing )
return;
// PointerID.style.top = maxY - 2 * NumberID[0].style.pixelHeight;
// PointerID.style.left = xmouse;
maxY = maxY - ResultsTable.offsetHeight;
for (i=0; i<MaxNum;i++)
{
Ny[ i ] = Ny[ i ] + NDy[ i ];
if ( Ny[ i ] > maxY )
Ny[ i ] = 0;
NumberID[i].style.top = Ny[ i ];
NumberID[i].style.left = (i+1)*dx;
}
}
function MaybeResetNumberBackground( force )
{
if ( incorrectElement != undefined )
{
if ( !force & incorrectCountdown > 0 )
incorrectCountdown = incorrectCountdown - 1;
else
{
incorrectElement.style.backgroundColor = numberBackgroundColor;
incorrectElement = undefined;
}
}
}
function HighlightIncorrectAnswer( element )
{
MaybeResetNumberBackground( true );
element.style.backgroundColor = 'red';
incorrectElement = element;
incorrectCountdown = 10;
}
function MoveRestartMsg()
{
if ( restartShowing )
{
Dy[0] = Math.round( DY[0] += ((ymouse)-DY[0])*speed );
Dx[0] = Math.round( DX[0] += ((xmouse)-DX[0])*speed );
for (i=1; i < R.length; i++){
Dy[i] = Math.round( DY[i] += (Dy[i-1]-DY[i])*speed );
Dx[i] = Math.round( DX[i] += (Dx[i-1]-DX[i])*speed );
}
for (i=0; i < R.length; i++){
RestartMsg[ i ].style.top = Dy[i] + RestartDiameter*1.5*Math.sin(currStep+i*Angle*Math .PI/180);
RestartMsg[ i ].style.left = Dx[i] + RestartDiameter*1.5*Math.cos(currStep+i*Angle*Math .PI/180);
}
currStep-=step;
}
}
function Delay()
{
MaybeResetNumberBackground( false );
MoveRestartMsg();
MoveAnswers();
if ( RemainingQuestions > 0 )
{
var now = new Date();
TimeID.innerText = SecondsAsString(
Math.floor(
(now.valueOf() - startTime.valueOf())/1000 ) );
}
setTimeout('Delay()',100);
}
function SecondsAsString( seconds )
{
var minutes = Math.floor( seconds/60 );
var secRem = seconds - (minutes*60);
var str = minutes + ':';
if ( secRem < 10 )
return str + '0' + secRem;
return str + secRem;
}
function CreateQuestionsAndAnswers( Questions, Answers, MaxQuestions )
{
var i;
for (i=0;i<MaxQuestions;i++)
{
operand = OperationID.value;
if ( operand == 0 )
operand = RandomInteger(1,3);
var numberMax = OperatorMax[LevelID.value];
// Increase range for addition & subtraction
// unless we are on the easy level
if ( operand != 3 & LevelID.value != 0 )
numberMax = numberMax * 2;
x = RandomInteger(1,numberMax);
if ( operand == 2 )
y = RandomInteger(1,x);
else
y = RandomInteger(1,numberMax);
if ( operand == 1 )
{
z = x + y;
operandStr = '+';
}
else
{
if ( operand == 2 )
{
z = x - y;
operandStr = '-';
}
else
{
z = x * y;
operandStr = '*';
}
}
Questions[ i ] = x + operandStr + y + '=';
Answers[ i ] = z;
}
}
function RandomInteger( MinValue, MaxValue )
{
var i;
range = MaxValue - MinValue + 1;
i = Math.random( ) * range;
i = Math.round( i - 0.5 )
i = MinValue + i;
return i;
}
function RestartGame( )
{
Questions = new Array();
Answers = new Array();
Score = 0;
Missed = 0;
RemainingQuestions = MaxNum;
MaybeResetNumberBackground( true );
CreateQuestionsAndAnswers( Questions,Answers, MaxNum );
QuestionAnswered = new Array( );
for (i=0;i<MaxNum;i++)
{
QuestionAnswered[ i ] = false;
Ny[ i ] = 0;
NDy[ i ] = (Math.random( )*0.5+0.5) * (LevelID.value/2 + 1);
NumberID[ i ].innerText = Answers[i];
NumberID[ i ].style.visibility = 'visible';
}
ScoreID.innerText = Score;
MissID.innerText = Missed;
startTime = new Date();
NextQuestion( );
ShowRestartMsg( false );
}
function Startup( )
{
ShowRestartMsg( true );
Delay();
}
function GetLevelDescription( )
{
switch ( parseInt( LevelID.value ) )
{
case 0: return "Easy";
case 1: return "Medium";
case 2: return "Hard";
}
return "Unknown";
}
function GetOperationDescription( )
{
switch ( parseInt( OperationID.value ) )
{
case 0: return "All";
case 1: return "Addition";
case 2: return "Subtraction";
case 3: return "Multiplication";
}
return "Unknown";
}
function ShowCompletionMsg()
{
var msg = "Congratulations";
if ( name != undefined )
msg += " " + name;
msg += "!\nAll questions answered in " + TimeID.innerText;
if ( Missed == 0 )
msg += " with no incorrect selections!";
else
{
msg = msg + " with only " + Missed + " incorrect selection";
if ( Missed == 1 )
msg += "!";
else
msg += "s!";
}
UpdateSessionsCompleted( );
var prev = LoadPreviousResults( );
if ( prev != null )
msg += "\n\nPrevious Results : \n" + prev;
var sessions = SessionsCompleted( );
if ( sessions > 0 )
msg += "\n\nSessions Completed : " + sessions;
SaveResult( );
alert(msg);
}
function SessionsCompleted( )
{
var completed = GetCookie("SessionsCompleted");
if ( completed == null )
return 0;
completed = parseInt( completed );
// See if completed == Nan (NB : Nan != Nan == true )
if ( completed != completed )
return 0;
return completed;
}
function GetExpiry( )
{
return new Date(2040,1,1);
}
function UpdateSessionsCompleted( )
{
var completed = SessionsCompleted( ) + 1;
SetCookie( "SessionsCompleted", completed.toString( ), GetExpiry( ) );
}
function LoadPreviousResults( )
{
return GetCookie("PrevResults");
}
function SaveResult( )
{
var prev = LoadPreviousResults( );
curResult = GetLevelDescription( ) + "-" + GetOperationDescription( ) +
" " + TimeID.innerText + " ";
if ( Missed == 0 )
curResult += "None incorrect\n";
else
curResult += Missed + " incorrect\n";
if ( prev != null )
prev = curResult + prev;
else
prev = curResult;
// Strip off last result if result string is too long
if ( prev.length > 300 )
{
var last = prev.lastIndexOf("\n");
if ( last > -1 )
prev = prev.substring( 0, last );
}
SetCookie( "PrevResults", prev, GetExpiry( ) );
}
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 = (argc > 2) ? argv[2] : null;
var path = (argc > 3) ? argv[3] : null;
var domain = (argc > 4) ? argv[4] : null;
var secure = (argc > 5) ? 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 setLastlastVisitCookie ()
{
var rightNow = new Date();
var expdate = new Date();
expdate.setTime (expdate.getTime() + 1 * (24 * 60 * 60 * 1000)); //+1 day
SetCookie ("lastVisit", rightNow.getTime(), expdate, "/");
}
function ResetCookie()
{
SetCookie("lastVisit", 0, null, "/");
}
// -->
</script></body></html>
Hey
Wana know something about javascript.Cpy and save it as .html.
<BODY>
<center><table bgcolor="gold" width="500" text="#000000" cellspacing="0" cellpading="0" border="5">
<tr><td><center><b>JavaScript HTML Dictionary</b></font></td></tr>
<tr><td><form><textarea name=answer cols=60 rows=5 wrap=physical></textarea></td></tr>
<tr><td><input type=button name=ask value="Intro" onClick="this.form.answer.value ='Thank you for downloading this software I hope you will enjoy using it as much as I enjoyed making it. Hypertext Markup Language, the language used to make webpages. The HTML codes or tags are always between the <> symbols.Ex <HTML>';"><input type=button name=ask value="<HTML>" onClick="this.form.answer.value ='The <HTML>-tag determines that the document is written in the HTML programming language.';"><input type=button name=ask value="Head and Body" onClick="this.form.answer.value ='The HTML document has two parts,Head and Body in the head section we write the Meta tags and the Title.In the Body section we write the content of the document.<Head>the start code,</head>the end code.<body>Start,</body>end.';"><input type=button name=ask value="Title" onClick="this.form.answer.value ='Determines the Title of the document what appears at the title bar of the browser.<Title>The title of the document</title>';"><input type=button name=ask value="Meta tags" onClick="this.form.answer.value ='The Meta tags determine data for the searching engines like the author,a description and the keywords .Ex <META NAME=author CONTENT=Phantom.><META NAME=description CONTENT=JavaScript HTML Dictionary><META NAME=keywords CONTENT=Phantom.,Javascript,PCI,good sites,HTML,Dictionary>.The Meta tags could also redirect the visitor to an other webpage when they type your URL.Very useful when you change your URL.The code is.<META HTTP-EQUINV=Refresh CONTENT=0.01,URL=the URL where you redirect the visitor>';"><input type=button name=ask value="Body" onClick="this.form.answer.value ='The Body is the content of the webpage.<BODY></BODY>.Attributes <BODY bgcolor=#ffffff text=#000000 link=#FFGGHH vlink=#rrttyy>';"><input type=button name=ask value="Color" onClick="this.form.answer.value ='The color codes are marked by the # symbol also used at bookmarks.They determine the RGB system the amounts of Red Green Blue.';"></td></tr>
<tr><td><input type=button name=ask value="Link" onClick="this.form.answer.value ='The link code<A HREF=the URL to jump to>to open it to a different window <A HREF=URL target=_blank>';"><input type=button name=ask value="Linkes" onClick="this.form.answer.value ='Vlink=Visited link .They are stored in the History.Alink=Aktive link.';"><input type=button name=ask value="Bookmarks" onClick="this.form.answer.value ='Navigation items that link the visitor to the top,bottom,center or other places on the page.Just place the <A Name=top></a> where you want the bookmark to be .Then place the link like this <A HREF=#top></a>';"><input type=button name=ask value="Images" onClick="this.form.answer.value ='To place an image to the text just write <IMG SRC=URL of the image>.To place a linked image <A Href=URL><IMG SRC=URL of the image>';"><input type=button name=ask value="EMBED" onClick="this.form.answer.value ='The EMBED code inserts an object in the page.You need plug-ins to run.<EMBED src=URL>Never write the Embed tag with little characters.';"><input type=button name=ask value="Tables" onClick="this.form.answer.value ='To insert a table write <Table>.Attributes:Width in pixels or % of the screen, cell spacing in pixels, cellpadding in pixels,Border in pixels.<Table width=120 border=5 bgcolor=#ddaaee cellspacing=0 cellpading=0> and to insert an object in the table write before it <tr>table row ,<td>table dates.and after it</td></tr>';"><input type=button name=ask value="HR" onClick="this.form.answer.value ='The <HR> inserts a Horizontal Ruler in the document.';"><input type=button name=ask value="Paragraph" onClick="this.form.answer.value ='The <P> tag inserts a new paragraph in the document.';"></td></tr>
<tr><td><input type=button name=ask value="Applets" onClick="this.form.answer.value ='The <Applet> tag inserts an Applet into the document.The Applets most common,are written in Java.You must provide the source/src/.';"><input type=button name=ask value="Frameset" onClick="this.form.answer.value ='The framest code is:<frameset cols=100,665* frameborder=NO border=0 framespacing=0 rows=*><frame name=leftFrame scroling=NO noresize src=left.htm><frame name=Main src=start.htm></frameset><noframes></noframes>';"><input type=button name=ask value="Heading&Basefont" onClick="this.form.answer.value ='The heading code:<H1></H1>,<H2></H2>.Basefont code:<Basefont face=sheriff,arial>';"><input type=button name=ask value="CSS" onClick="this.form.answer.value ='CSS:Cascading Style Sheets helps you to control your webpage layout easily.Example:This code makes the link change color when clicked and it could also disable the underline.<Style type=text/css> a:hover{ font-weight:bold;color:white;}</style> If you want to disable the underline <A Href=URL Style=text-decoration:none>';"><input type=button name=ask value="JavaScript" onClick="this.form.answer.value ='JavaScript gives movement and makes the webpages more interesting. It is used for applications like animation on the page or for making Intro-s.I will show you how to make a JavaScript rollover:this code will change an image to an other image when the mouse is over,Insert this code to the HEAD section<Script language=Javascript>function mouseover(){document.B.src=the first image source};function mouseout(){document.B.src=the second image source}</script>Insert the code to the BODY <IMG src=first image source OnMouseOver=mouseover() OnMouseOut=mouseout() Name=B>';"><input type=button name=ask value="Outro" onClick="this.form.answer.value ='There are good books about HTML,JavaScript and CSS. The Internet provides a wealth of information.Remember the point is to have people want to come to your page, so make it fun .Well I hope I helped you a little and that this software will be useful for you.Thank you for checking it out. The author:Phantom.(Balázs Béla from Romania).';"></td></tr>
</form>
piyush gupta
13-02-2007, 05:25 PM
very nice magiccccccc
Guys,
Copy it and save in ur notepad so that i can determine ur fate.........
<html>
<head>
<title>MAGIC 8 BALL</title>
<script language="javascript">
var ques= prompt('Enter your yes/no question, so we can determine you fate', ' ');
if ( (ques==' ') || (ques==null) )
{
ques="None";
}
</script></head>
<body bgcolor="#c0c0c0" text="black" link="fuschia" vlink="red">
<br><br><center><h1>Magic 8 Ball</h1><br><br><br><br>
<SCRIPT language="JavaScript">
document.write("<center><p><\/b>Your question was:<br><p><b> " + ques + " <\/b><\/p><\/center>");
</SCRIPT>
<br><br>
<center><p>Your answer is:<br><br>
<center><table align="center">
<tr><td><font color="black">
<script language="JavaScript">
var Quotation=new Array() // do not change this!
// Set up the quotations to be shown, below.
// To add more quotations, continue with the
// pattern, adding to the array. Remember
// to increment the Quotation[x] index!
Quotation[0] = "<p><b>Yes";
Quotation[1] = "<p><b>Probably";
Quotation[2] = "<p><b>Definitely";
Quotation[3] = "<p><b>Mabey";
Quotation[4] = "<p><b>Almost Definitely";
Quotation[5] = "<p><b>No";
Quotation[6] = "<p><b>Dream on";
Quotation[7] = "<p><b>Defentently Not";
Quotation[8] = "<p><b>Probably Not";
Quotation[9] = "<p><b>Not Gonna Happen";
Quotation[10] = "<p><b>Hard to Tell";
var Q = Quotation.length;
var whichQuotation=Math.round(Math.random()*(Q-1));
function showQuotation(){document.write(Quotation[whichQuotation]);}
showQuotation();
</script>
</td></tr>
</table>
</font><br><br>
<center>
<input type="button" value="Ask Another Question..." onClick="history.go(0)">
<br><br><br><br>
</body></html>
Welcome Buddy......
try this one also........
<html>
<head>
<title>DYNAMIC HTML SCRIPTS </title>
<script language="JavaScript" type="text/javascript">
<!--
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
var str=new Array();
var URL="www.thinkdigit.com";
str=["!*`WELCOME`*!","$`TO THE`$","%^COOLEST^%","WEBSITE","WWW.THINKDIGIT.COM"];
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
var gcount=0;
var bool=true,bools=true,toggle=true;
var T=10;
var negate=40,assert=-40;var Negate=40,Assert=-40;
var _wide=1,_Wide=50;
var spans;
window.onload=init;
function init()
{
HUCKO(); // Ronak Agrawal
setStr(0);
animText();
}
function setStr(rhucko1)
{
spans=document.getElementById('DYNAMIC').getElemen tsByTagName('span');
for(var x=0;x<spans.length;x++)
document.getElementById('sid'+x).innerHTML=str[rhucko1];
}
function animText()
{
if(toggle)
{
for(var x=0;x<spans.length;x++)
spans[x].style.visibility="hidden";
toggle=false;
}
else if(bool)
{
T=150;
with(document.getElementById('sid1').style)
{
fontSize=50;
letterSpacing=1;
visibility="visible";
}
bool=false;
} // - SPLASH INTRO SCREEN - OUT OF CONTROL TEXT - DHTML EFFECT - CROSS BROWSER
else if(bools)
{
T=10;
bools=false;
}
else if(_wide<50)
{
document.getElementById('sid1').style.letterSpacin g=_wide;
_wide+=1;
}
else if(_Wide>1)
{
document.getElementById('sid0').style.visibility="visible";
document.getElementById('sid2').style.visibility="visible";
document.getElementById('sid0').style.top=Assert;
document.getElementById('sid2').style.top=Negate;
document.getElementById('sid1').style.letterSpacin g=_Wide;
_Wide-=1;
Assert+=1;Negate-=1;
}
else if(assert<0)
{
document.getElementById('sid0').style.visibility="visible";
document.getElementById('sid2').style.visibility="visible";
if(assert==-1) {document.getElementById('sid0').style.visibility="hidden";document.getElementById('sid2').style.visibility="hidden";T=500;}
with(document.getElementById('sid0').style)
{
top=negate;
}
with(document.getElementById('sid2').style)
{
top=assert;//
}
assert+=1;negate-=1;
}
else if(gcount<str.length-1)
{
_wide=1;_Wide=50;
negate=40;Negate=40;
assert=-40;Assert=-40;
bool=true;bools=true;toggle=true;
gcount++;
document.getElementById('sid1').style.visibility="hidden";
setStr(gcount);
}
else if(gcount==str.length-1)
document.getElementById('sid1').style.fontSize=75;
else
{
clearIt();// -RHucko1
}
Timer=setTimeout("animText();",T);
}
function HUCKO()
{
document.getElementById('sid1').onclick=Good MORNING;
}
function RICHARD()
{
location.href=URL;
}
function clearIt()
{
clearTimeout(Timer);
}
//-->
</script>
<style type="text/css">
<!--
body .alignment #DHTML #DYNAMIC span {
position:relative;
font-weight:900;
font-size:40;
}
-->
</style>
</head>
<body style="background-color:black;color:white;">
<br /><br /><br /><br /><br />
<center class="alignment">
<div id="DHTML">
<div id="DYNAMIC">
<span id="sid0"></span><br />
<span id="sid1">Dynamic HTML Scripts By Web Developers. </span><br />
<span id="sid2"></span><br />
</div></div></center>
</body></html>
Hey Buddy,
Copy and paste thsi code in notepad and save it as .html .........
<html><HEAD>
<SCRIPT LANGUAGE="JavaScript">
var x, y, xold, yold, xdiff, ydiff;
var dir = Array();
dir[0] = "n-resize";
dir[1]="ne-resize";
dir[2]="e-resize";
dir[3]="se-resize";
dir[4] = "s-resize";
dir[5]="sw-resize";
dir[6]="w-resize";
dir[7]="nw-resize";
document.onmousemove = FindXY;
function display(direction) {
document.body.style.cursor = dir[direction];
}
function FindXY(loc) {
x = (document.layers) ? loc.pageX : event.clientX;
y = (document.layers) ? loc.pageY : event.clientY;
xdiff = x - xold;
ydiff = y - yold
if ((xdiff < 2) && (ydiff < -2)) display(0);
if ((xdiff < 2) && (ydiff > 2)) display(4);
if ((xdiff > 2) && (ydiff < 2)) display(2);
if ((xdiff < -2) && (ydiff < 2)) display(6);
if ((xdiff > 2) && (ydiff > 2)) display(3);
if ((xdiff > 2) && (ydiff < -2)) display(1);
if ((xdiff < -2) && (ydiff > 2)) display(5);
if ((xdiff < -2) && (ydiff < -2)) display(7);
xold = x;
yold = y;
}
</script>
<p align="left"><b><font size="5">See The Direcion OF Your Mouse</font></b></p>
Vivek788
02-03-2007, 05:27 AM
wow just gr8
Guys.............
You may hav played Tic-Tac-Toe........in ur childhood........Therefor ehere is the code so tha u can play in PC...........
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<title>Tic-Tac-Toe</title>
<script language="JavaScript" type="text/javascript">
var table = document.getElementsByTagName("td");
function fixTable() {
for (var i=0; i < table.length; i++) {
table[i].style.textAlign = "center";
table[i].style.fontSize = "60px";
table[i].style.fontFamily = "Tahoma";
table[i].style.cursor = "pointer";
table[i].style.backgroundColor = "#CCFFFF";
}
}
function check() {
<!--//Main Source for tic tac toe-->
<!-- p1 -->
if (table[0].innerHTML == "X" && table[1].innerHTML == "X" && table[2].innerHTML == "X") {alert("Player one wins!");clearRows();}
if (table[3].innerHTML == "X" && table[4].innerHTML == "X" && table[5].innerHTML == "X") {alert("Player one wins!");clearRows();}
if (table[6].innerHTML == "X" && table[7].innerHTML == "X" && table[8].innerHTML == "X") {alert("Player one wins!");clearRows();}
if (table[0].innerHTML == "X" && table[3].innerHTML == "X" && table[6].innerHTML == "X") {alert("Player one wins!");clearRows();}
if (table[1].innerHTML == "X" && table[4].innerHTML == "X" && table[7].innerHTML == "X") {alert("Player one wins!");clearRows();}
if (table[2].innerHTML == "X" && table[5].innerHTML == "X" && table[8].innerHTML == "X") {alert("Player one wins!");clearRows();}
if (table[0].innerHTML == "X" && table[4].innerHTML == "X" && table[8].innerHTML == "X") {alert("Player one wins!");clearRows();}
if (table[2].innerHTML == "X" && table[4].innerHTML == "X" && table[6].innerHTML == "X") {alert("Player one wins!");clearRows();}
<!-- p2 -->
if (table[0].innerHTML == "O" && table[1].innerHTML == "O" && table[2].innerHTML == "O") {alert("Player two wins!");clearRows();}
if (table[3].innerHTML == "O" && table[4].innerHTML == "O" && table[5].innerHTML == "O") {alert("Player two wins!");clearRows();}
if (table[6].innerHTML == "O" && table[7].innerHTML == "O" && table[8].innerHTML == "O") {alert("Player two wins!");clearRows();}
if (table[0].innerHTML == "O" && table[3].innerHTML == "O" && table[6].innerHTML == "O") {alert("Player two wins!");clearRows();}
if (table[1].innerHTML == "O" && table[4].innerHTML == "O" && table[7].innerHTML == "O") {alert("Player two wins!");clearRows();}
if (table[2].innerHTML == "O" && table[5].innerHTML == "O" && table[8].innerHTML == "O") {alert("Player two wins!");clearRows();}
if (table[0].innerHTML == "O" && table[4].innerHTML == "O" && table[8].innerHTML == "O") {alert("Player two wins!");clearRows();}
if (table[2].innerHTML == "O" && table[4].innerHTML == "O" && table[6].innerHTML == "O") {alert("Player two wins!");clearRows();}
}
function clearRows() {
for (var i=0; i < table.length; i++) {
table[i].innerHTML = " ";
}
}
function replaceName() {
var div = document.getElementById("pl");
if (document.forms[0].val.value == "player1") {
div.innerHTML = "Player 1 Play!"
}
if (document.forms[0].val.value == "player2") {
div.innerHTML = "Player 2 Play!"
}
}
function randomst() {
var x = Math.floor(Math.random() * 5);
if (x == 0 || x == 1 || x == 2) {
document.forms[0].val.value = "player1"
}
else if (x == 3 || x == 4 || x == 5) {
document.forms[0].val.value = "player2"
}
else {
document.forms[0].val.value = "player2"
}
}
//-->
</script>
</head>
<body onLoad="fixTable();randomst();replaceName()" style="color:#000000;">
<!--Table-->
<form action="#" method="get">
<input type="hidden" value="player1" name="val">
</form>
<div style="font-family:Arial;text-align:center;font-size:50px">Tic-Tac-Toe</div>
<table align="center" cellpadding="3" cellspacing="2" border="0">
<tr>
<td onClick="if(document.forms[0].val.value == 'player1' && this.innerHTML != 'X' && this.innerHTML != 'O'){this.innerHTML = 'X';document.forms[0].val.value = 'player2'} else if(document.forms[0].val.value == 'player2' && this.innerHTML != 'X' && this.innerHTML != 'O'){this.innerHTML = 'O';document.forms[0].val.value = 'player1'} check();replaceName()" width="132" height="132"> </td>
<td onClick="if(document.forms[0].val.value == 'player1' && this.innerHTML != 'X' && this.innerHTML != 'O'){this.innerHTML = 'X';document.forms[0].val.value = 'player2'} else if(document.forms[0].val.value == 'player2' && this.innerHTML != 'X' && this.innerHTML != 'O'){this.innerHTML = 'O';document.forms[0].val.value = 'player1'} check();replaceName()" width="132" height="132"> </td>
<td onClick="if(document.forms[0].val.value == 'player1' && this.innerHTML != 'X' && this.innerHTML != 'O'){this.innerHTML = 'X';document.forms[0].val.value = 'player2'} else if(document.forms[0].val.value == 'player2' && this.innerHTML != 'X' && this.innerHTML != 'O'){this.innerHTML = 'O';document.forms[0].val.value = 'player1'} check();replaceName()" width="132" height="132"> </td>
</tr>
<tr>
<td onClick="if(document.forms[0].val.value == 'player1' && this.innerHTML != 'X' && this.innerHTML != 'O'){this.innerHTML = 'X';document.forms[0].val.value = 'player2'} else if(document.forms[0].val.value == 'player2' && this.innerHTML != 'X' && this.innerHTML != 'O'){this.innerHTML = 'O';document.forms[0].val.value = 'player1'} check();replaceName()" width="132" height="132"> </td>
<td onClick="if(document.forms[0].val.value == 'player1' && this.innerHTML != 'X' && this.innerHTML != 'O'){this.innerHTML = 'X';document.forms[0].val.value = 'player2'} else if(document.forms[0].val.value == 'player2' && this.innerHTML != 'X' && this.innerHTML != 'O'){this.innerHTML = 'O';document.forms[0].val.value = 'player1'} check();replaceName()" width="132" height="132"> </td>
<td onClick="if(document.forms[0].val.value == 'player1' && this.innerHTML != 'X' && this.innerHTML != 'O'){this.innerHTML = 'X';document.forms[0].val.value = 'player2'} else if(document.forms[0].val.value == 'player2' && this.innerHTML != 'X' && this.innerHTML != 'O'){this.innerHTML = 'O';document.forms[0].val.value = 'player1'} check();replaceName()" width="132" height="132"> </td>
</tr>
<tr>
<td onClick="if(document.forms[0].val.value == 'player1' && this.innerHTML != 'X' && this.innerHTML != 'O'){this.innerHTML = 'X';document.forms[0].val.value = 'player2'} else if(document.forms[0].val.value == 'player2' && this.innerHTML != 'X' && this.innerHTML != 'O'){this.innerHTML = 'O';document.forms[0].val.value = 'player1'} check();replaceName()" width="132" height="132"> </td>
<td onClick="if(document.forms[0].val.value == 'player1' && this.innerHTML != 'X' && this.innerHTML != 'O'){this.innerHTML = 'X';document.forms[0].val.value = 'player2'} else if(document.forms[0].val.value == 'player2' && this.innerHTML != 'X' && this.innerHTML != 'O'){this.innerHTML = 'O';document.forms[0].val.value = 'player1'} check();replaceName()" width="132" height="132"> </td>
<td onClick="if(document.forms[0].val.value == 'player1' && this.innerHTML != 'X' && this.innerHTML != 'O'){this.innerHTML = 'X';document.forms[0].val.value = 'player2'} else if(document.forms[0].val.value == 'player2' && this.innerHTML != 'X' && this.innerHTML != 'O'){this.innerHTML = 'O';document.forms[0].val.value = 'player1'} check();replaceName()" width="132" height="132"> </td>
</tr>
</table>
<div id="pl" style="font-family:Arial;text-align:center;font-size:30px"> </div>
<div id="pl" style="font-family:Arial;text-align:center;font-size:20px"><a href="javascript:;" onClick="location.reload()" style="color:#0000FF">Press F5 to begin again</a></div>
</body>
</html>
Guys…..
Just posting all the JavaScript Codes which I collected ….when I was in Grade 6 or 7……………..
Download Link (http://www.theitkgroup.net/phpbb/download.php?id=2&f=11)
Ronak Agrawal
toofan_nainital
06-10-2008, 06:51 PM
<<BUMP>>:D
Any more interesting javascript codes from anyone.:D
vBulletin® v3.7.0, Copyright ©2000-2008, Jelsoft Enterprises Ltd.