Free Games Forum
Free Games Games Forums Music Forums TV Forums

  Free Games Forum Home FORUM
HOME
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN
Rules & FAQ RULES / FAQ
REPORT SPAM

Free Games Forum: Game Technology: Javascript Coding:
what is....

 

 


Raziel The Soul Reaver
Senior Member


Jan 24, 2005, 9:59 AM

Post #1 of 9 (628 views)
Shortcut
what is.... Can't Post

the javascript code for making words follow the mouse on websites?



"For every animal you don't eat, i'm going to eat three"
Quote: Maddox



JaVa CoDe
Senior Member


Jan 25, 2005, 9:17 AM

Post #2 of 9 (621 views)
Shortcut
Re: [Raziel The Soul Reaver] what is.... [In reply to] Can't Post

Oh man I could give you it tommorrow or you could just search it.



My train of thought has been delayed.


Cruel__Machine
Senior Member


Jan 30, 2005, 5:10 PM

Post #3 of 9 (601 views)
Shortcut
Re: [Raziel The Soul Reaver] what is.... [In reply to] Can't Post

This is probably the most annoying and useless scripts out there, but you asked...

Put this in the <HEAD>:

<style>.spanstyle {
COLOR: white; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; FONT-WEIGHT: bold; POSITION: absolute; TOP: -50px; VISIBILITY: visible
}
</style>

<SCRIPT LANGUAGE="JavaScript">
var x, y;
var step = 10;
var flag = 0;

var message = "TEXT TEXT TEXT BLAH BLAH BLAH";
message = message.split("");
var xpos = new Array();
for (i = 0; i <= message.length - 1; i++) {
xpos = -50;
}
var ypos = new Array();
for (i = 0; i <= message.length - 1; i++) {
ypos= -50;
}
function handlerMM(e) {
x = (document.layers) ? e.pageX : document.body.scrollLeft + event.clientX;
y = (document.layers) ? e.pageY : document.body.scrollTop + event.clientY;
flag = 1;
}
function makesnake() {
if (flag == 1 && document.all) {
for (i = message.length - 1; i >= 1; i--) {
xpos = xpos[i - 1] + step;
ypos = ypos[i - 1];
}
xpos[0] = x + step;
ypos[0] = y;
for (i = 0; i < message.length - 1; i++) {
var thisspan = eval("span" + (i) + ".style");
thisspan.posLeft = xpos;
thisspan.posTop = ypos;
}
}
else if (flag==1 && document.layers) {
for (i = message.length - 1; i >= 1; i--) {
xpos = xpos[i - 1] + step;
ypos = ypos[i - 1];
}
xpos[0] = x + step;
ypos[0] = y;
for (i = 0; i < message.length - 1; i++) {
var thisspan = eval("document.span" + i);
thisspan.left = xpos;
thisspan.top = ypos;
}
}
var timer = setTimeout("makesnake()", 10);
}
</script>




Edit your body tag to load the script like so:

<body bgcolor="#000080" text="#000000" onload="makesnake()"
style="OVERFLOW-X: hidden; OVERFLOW-Y: scroll; WIDTH: 100%">


Then put this into your body:

<SCRIPT LANGUAGE="JavaScript">
for (i = 0; i <= message.length-1; i++) {
document.write("<span id='span"+i+"' class='spanstyle'>");
document.write(message);
document.write("</span>");
}
if (document.layers) {
document.captureEvents(Event.MOUSEMOVE);
}
document.onmousemove = handlerMM;

</script>




That should work... and BTW, I didn't write all that. LMAO... I'm not THAT nice.


EOP
___________________________
"If evolution were true, I'd have a self-lubricating hand."

Programmers: http://Cruels.net


Raziel The Soul Reaver
Senior Member


Feb 7, 2005, 11:22 AM

Post #4 of 9 (593 views)
Shortcut
Re: [Raziel The Soul Reaver] what is.... [In reply to] Can't Post

thanks man



"For every animal you don't eat, i'm going to eat three"
Quote: Maddox


Raziel The Soul Reaver
Senior Member


Feb 7, 2005, 11:32 AM

Post #5 of 9 (592 views)
Shortcut
Re: [Raziel The Soul Reaver] what is.... [In reply to] Can't Post

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
<style>.spanstyle {
COLOR: red; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; FONT-WEIGHT: bold; POSITION: absolute; TOP: -50px; VISIBILITY: visible
}
</style>

<SCRIPT LANGUAGE="JavaScript">
var x, y;
var step = 10;
var flag = 0;

var message = "Welcome To Omega Online";
message = message.split("");
var xpos = new Array();
for (i = 0; i <= message.length - 1; i++) {
xpos = -50;
}
var ypos = new Array();
for (i = 0; i <= message.length - 1; i++) {
ypos= -50;
}
function handlerMM(e) {
x = (document.layers) ? e.pageX : document.body.scrollLeft + event.clientX;
y = (document.layers) ? e.pageY : document.body.scrollTop + event.clientY;
flag = 1;
}
function makesnake() {
if (flag == 1 && document.all) {
for (i = message.length - 1; i >= 1; i--) {
xpos = xpos[i - 1] + step;
ypos = ypos[i - 1];
}
xpos[0] = x + step;
ypos[0] = y;
for (i = 0; i < message.length - 1; i++) {
var thisspan = eval("span" + (i) + ".style");
thisspan.posLeft = xpos;
thisspan.posTop = ypos;
}
}
else if (flag==1 && document.layers) {
for (i = message.length - 1; i >= 1; i--) {
xpos = xpos[i - 1] + step;
ypos = ypos[i - 1];
}
xpos[0] = x + step;
ypos[0] = y;
for (i = 0; i < message.length - 1; i++) {
var thisspan = eval("document.span" + i);
thisspan.left = xpos;
thisspan.top = ypos;
}
}
var timer = setTimeout("makesnake()", 10);
}
</script>

<title>Omega Online</title>

</head>

<body>

<body bgcolor="#000080" text="#000000" onload="makesnake()"
style="OVERFLOW-X: hidden; OVERFLOW-Y: scroll; WIDTH: 100%">
<text=red>

<SCRIPT LANGUAGE="JavaScript">
for (i = 0; i <= message.length-1; i++) {
document.write("<span id='span"+i+"' class='spanstyle'>");
document.write(message);
document.write("</span>");
}
if (document.layers) {
document.captureEvents(Event.MOUSEMOVE);
}
document.onmousemove = handlerMM;

</script>

<style>
A {text-decoration : none}
A:hover {text-decoration : underline , overline ; color : silver}
</style>

<embed src="omegaonline.mid" width="1"
height="1" autostart="true" hidden="true
loop="true">
<br>
<br>
<br>
<align=center><text=red><i>Omega Online is a new game with the classic graphics that people of mmorpg have always wanted. Taking you back into the 80's with the SNES graphics, this client based game, will soon sweep the nation. But why listen to me, download the client, and take a stab at it.</i></text></align>
<br>
<br>

<a href="index.html">Home Page</a> | <a href="nextpagedomain.html">Page 2</a>

</body>
</html>

can u fix that for me? i put in wut u said, but its not workingUnsure



"For every animal you don't eat, i'm going to eat three"
Quote: Maddox


Cruel__Machine
Senior Member


Feb 7, 2005, 11:46 AM

Post #6 of 9 (590 views)
Shortcut
Re: [Raziel The Soul Reaver] what is.... [In reply to] Can't Post

ok.. one sec.. i'll look it over.


EOP
___________________________
"If evolution were true, I'd have a self-lubricating hand."

Programmers: http://Cruels.net


Raziel The Soul Reaver
Senior Member


Feb 7, 2005, 11:53 AM

Post #7 of 9 (583 views)
Shortcut
Re: [Cruel__Machine] what is.... [In reply to] Can't Post

kk thanks



"For every animal you don't eat, i'm going to eat three"
Quote: Maddox


Cruel__Machine
Senior Member


Feb 7, 2005, 12:10 PM

Post #8 of 9 (580 views)
Shortcut
Re: [Raziel The Soul Reaver] what is.... [In reply to] Can't Post

well... first off I noticed that you posted the body tag part inside a body tag. But I meant for you to replace the body tag with that section. But I still tryed it and it didn't work for some reason... So I got a different method of doing it.
Here is the full code:


<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
<SCRIPT LANGUAGE="JavaScript">
message = 'MESSAGE HERE!!!!!';
FonT = 'Verdana';
ColoR = '999999';
SizE = 3; //1 to 7 only!

var amount = 5, ypos =- 50, xpos = 0, Ay = 0, Ax = 0, By = 0, Bx = 0, Cy = 0, Cx = 0, Dy = 0, Dx = 0, Ey = 0, Ex = 0;
if (document.layers) {
for (i = 0; i < amount; i++) {
document.write('<layer name=nsl'+i+' top=0 left=0><font face='+FonT+' size='+SizE+' color='+ColoR+'>'+message+'</font></layer>');
}
window.captureEvents(Event.MOUSEMOVE);
function nsmouse(evnt) {
xpos = evnt.pageX + 20;
ypos = evnt.pageY + 20;
}
window.onMouseMove = nsmouse;
}
else if (document.all) {
document.write("<div id='outer' style='position:absolute;top:0px;left:0px'>");
document.write("<div style='position:relative'>");
for (i = 0; i < amount; i++) {
document.write('<div id="text"'+i+' style="position:absolute;top:0px;left:0px;width:400px;height:20px"><font face='+FonT+' size='+SizE+' color='+ColoR+'>'+message+'</font></div>')
}
document.write("</div>");
document.write("</div>");
function iemouse() {
ypos = event.y + 20;
xpos = event.x + 20;
}
window.document.onmousemove = iemouse;
}
function makefollow() {
if (document.layers) {
document.layers['nsl'+0].top = ay;
document.layers['nsl'+0].left = ax;
document.layers['nsl'+1].top = by;
document.layers['nsl'+1].left = bx;
document.layers['nsl'+2].top = cy;
document.layers['nsl'+2].left = cx;
document.layers['nsl'+3].top = Dy;
document.layers['nsl'+3].left = Dx;
document.layers['nsl'+4].top = Ey;
document.layers['nsl'+4].left = Ex;
}
else if (document.all) {
outer.style.pixelTop = document.body.scrollTop;
text[0].style.pixelTop = ay;
text[0].style.pixelLeft = ax;
text[1].style.pixelTop = by;
text[1].style.pixelLeft = bx;
text[2].style.pixelTop = cy;
text[2].style.pixelLeft = cx;
text[3].style.pixelTop = Dy;
text[3].style.pixelLeft = Dx;
text[4].style.pixelTop = Ey;
text[4].style.pixelLeft = Ex;
}
}
function move() {
ey = Ey += (ypos - Ey) * 0.2;
ex = Ex += (xpos - Ex) * 0.2;
dy = Dy += (ey - Dy) * 0.3;
dx = Dx += (ex - Dx) * 0.3;
cy = Cy += (dy - Cy) * 0.4;
cx = Cx += (dx - Cx) * 0.4;
by = By += (cy - By) * 0.5;
bx = Bx += (cx - Bx) * 0.5;
ay = Ay += (by - Ay) * 0.6;
ax = Ax += (bx - Ax) * 0.6;
makefollow();
setTimeout('move()', 10);
}
window.onload=move;
</script>

</head>

<body>

</body>
</html>


EOP
___________________________
"If evolution were true, I'd have a self-lubricating hand."

Programmers: http://Cruels.net


Raziel The Soul Reaver
Senior Member


Feb 7, 2005, 12:16 PM

Post #9 of 9 (578 views)
Shortcut
Re: [Cruel__Machine] what is.... [In reply to] Can't Post

kk, thank you so much, ive been trying to find out how to do the word follow mosue thibng for a long time



"For every animal you don't eat, i'm going to eat three"
Quote: Maddox

 
 
 


Search for (options) Web Design by Web Ideas - Page loaded in: 0.15 s on (CGI/1.1)