PDA

View Full Version : Matrix effect code



.alias.
03-25-2006, 04:50 PM
Hi, let me know what you think. Be sure to change the URL to you home page in the reLoc(); function


<html>
<head>
<title>MATRIX TEXT!</title>
<script language="javascript">
function addC()
{
string = string.replace(/<([^<])*>/, ""); // Prevents HTML tags from effecting the page

if(x < string.length)
{
textBuffer += string.charAt(x);

dot = string.charAt(x); //Sets variable dot for checking

if (dot == ".") //Check for full stops in text
{ //If there is a full stop it
textBuffer=''; //starts a clean page
}

txt.innerHTML = textBuffer;
x++;
setTimeout('addC()', pause);
}

if (x == string.length)
{
setTimeout('reLoc()', (pause * 4)) // Send viewer to home page with pause to read text.
}

}

function reLoc()
{
window.location = "http://www.dynamicdrive.com"; // Send viewer to home page
}


</script>

</head>

<body bgcolor=#000000>


<font color="green">
<span id="text">This Script was created by .Alias .Do Not Remove commenting .

c[dot]alias[dot]s@hotmail[dot]co[dot]uk</span>
</font>

<script language="javascript">

/****************************
*THIS MUST NOT ME DELETED
*(c) .Alias.
*Contact c.alias.s@hotmail.co.uk
****************************/

/****************************
*Controls time between each Char.
*Change To Suit You
****************************/
pause = 150;

if (document.getElementById)
{

txt = document.getElementById("text");

if(txt.innerHTML)
{
textBuffer = " "; // Stops the loss of Spaces

x = 0;
string = txt.innerHTML;
txt.innerHTML = " ";
addC();
}
}

</script>

.alias.
03-25-2006, 06:31 PM
Ive made some changes to it so if you wanna see them let me know.

1) You chose delay bewtween each letter
2) You chose location to load at end or to not load and reapeat the test
3) You chose which ID i changes

also i can upload a working demo if you want

Twey
03-25-2006, 06:41 PM
I think we have one already :-\

.alias.
03-25-2006, 06:51 PM
OW i was beaten to it well any way her is my newest code

matrix.js

function addC()
{
string = string.replace(/<([^<])*>/, ""); // Prevents HTML tags from effecting the page

if(x < string.length)
{
textBuffer += string.charAt(x);

dot = string.charAt(x); //Sets variable dot for checking

if (dot == ".") //Check for full stops in text
{ //If there is a full stop it
textBuffer=''; //starts a clean page
}

txt.innerHTML = textBuffer;
x++;
setTimeout('addC()', pause);
}

if (x == string.length)
{
if (home == "")
{
x=0;
textBuffer = "";
}
else
{
setTimeout('reLoc()', (pause * 4)) // Send viewer to home page with pause to read text.
}
}

}

function reLoc()
{
window.location = home; // Send viewer to home page
}

function beginTxt(wanted, site, delay)
{
if (document.getElementById)
{
home = site;
pause = delay;
txt = document.getElementById(wanted);

if(txt.innerHTML)
{
textBuffer = " "; // Stops the loss of Spaces
x = 0;
string = txt.innerHTML;
txt.innerHTML = " ";
addC();
}
}
}

Your HTML document
in head

<script src="matrix.js"></script>

in body (text to have effect done to it)
id can be changed

<span id="blah">Example text . You text goes here Full stops cause screen to clear then carry on typeing</span>

at end of your body

<script language="javascript">

/****************************
*THIS MUST NOT BE DELETED
*(c) .Alias.
*Contact c.alias.s@hotmail.co.uk
****************************/

/****************************
*Controls time between each Char.
*Change To Suit You
****************************/

beginTxt("blah", "", 100);
// "blah" is the ID of <span>
// "" is URL to load after finished if left blank loops text
// 100 is pause between each letter
</script>


enjoy

Twey
03-25-2006, 06:56 PM
OW i was beaten to itSo long as yours is better, don't worry :p