Javascript Codes

Status
Not open for further replies.
OP
Ron

Ron

||uLtiMaTE WinNER||
Chetan1991 said:
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...................
 
OP
Ron

Ron

||uLtiMaTE WinNER||
Mathematical Game

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…………….


Code:
<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+';width:'+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>
 
OP
Ron

Ron

||uLtiMaTE WinNER||
Hey
Wana know something about javascript.Cpy and save it as .html.

Code:
<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>
 
OP
Ron

Ron

||uLtiMaTE WinNER||
Guys,
Copy it and save in ur notepad so that i can determine ur fate.........
Code:
<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>
 
OP
Ron

Ron

||uLtiMaTE WinNER||
Welcome Buddy......
try this one also........
Code:
<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').getElementsByTagName('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.letterSpacing=_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.letterSpacing=_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>
 
OP
Ron

Ron

||uLtiMaTE WinNER||
See The Direcion OF Your Mouse

Hey Buddy,
Copy and paste thsi code in notepad and save it as .html .........
Code:
<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>
 
OP
Ron

Ron

||uLtiMaTE WinNER||
Tutorial: Javascript Codes

Guys.............
You may hav played Tic-Tac-Toe........in ur childhood........Therefor ehere is the code so tha u can play in PC...........
Code:
<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>
 
OP
Ron

Ron

||uLtiMaTE WinNER||
Guys…..

Just posting all the JavaScript Codes which I collected ….when I was in Grade 6 or 7……………..

Download Link

Ronak Agrawal
 
Status
Not open for further replies.
Top Bottom