View Full Version : HTML Or Java Question
What are the codes to have my name or a line next to the mouse courser? it looks like when I move the mouse the line move as well
I wana use it for outlook-Express and my website
THX
Smizack
12-21-01, 11:00 AM
<style>
#pic1{position:absolute; }
</style>
<script>
//Copyright 2001 Chase Cathcart. Please leave this in here.
function trackit(){
document.all.pic1.style.left = event.x
document.all.pic1.style.top = event.y
if(event.x < "200"){
document.all.pic1.style.left = "200"
}
}
document.onmousemove = trackit
</script>
<img src="YOURNAME.gif" id="pic1">
Just change YOURNAME with a pic of your name.
I'm looking for more if you want each letter to move by itself.
Smizack
12-21-01, 11:08 AM
<script>
B=document.all;
C=document.layers;
T1=new Array("LETTER1.gif",38,35,"LETTER2.gif",30,31,"LETTER3.gif",28,26,"LETTER4.gif",22,21,"LETTER5.gif",16,16,"LETTER6.gif",10,10)
nos=parseInt(T1.length/3)
rate=50
ie5fix1=0;
ie5fix2=0;
for (i=0;i<nos;i++){
createContainer("CUR"+i,i*10,i*10,i*3+1,i*3+2,"","<img src='"+T1[i*3]+"' width="+T1[(i*3+1)]+" height="+T1[(i*3+2)]+" border=0>")}
function createContainer(N,Xp,Yp,W,H,At,HT,Op,St){
with (document){
write((!B) ? "<layer id='"+N+"' left="+Xp+" top="+Yp+" width="+W+" height="+H : "<div id='"+N+"'"+" style='position:absolute;left:"+Xp+"; top:"+Yp+"; width:"+W+"; height:"+H+"; ");
if(St){
if (C)
write(" style='");
write(St+";' ")
}
else write((B)?"'":"");
write((At)? At+">" : ">");
write((HT) ? HT : "");
if (!Op)
closeContainer(N)
}
}
function closeContainer(){
document.write((B)?"</div>":"</layer>")
}
function getXpos(N){
return (B) ? parseInt(B[N].style.left) : C[N].left
}
function getYpos(N){
return (B) ? parseInt(B[N].style.top) : C[N].top
}
function moveContainer(N,DX,DY){
c=(B) ? B[N].style :C[N];c.left=DX;c.top=DY
}
function cycle(){
//if (IE5)
if (document.all&&window.print){
ie5fix1=document.body.scrollLeft;
ie5fix2=document.body.scrollTop;
}
for (i=0;i<(nos-1);i++){
moveContainer("CUR"+i,getXpos("CUR"+(i+1)),getYpos("CUR"+(i+1)))
}
}
function newPos(e){
moveContainer("CUR"+(nos-1),(B)?event.clientX+ie5fix1:e.pageX+2,(B)?event.c lientY+ie5fix2:e.pageY+2
)
}
if(document.layers)
document.captureEvents(Event.MOUSEMOVE)
document.onmousemove=newPos
setInterval("cycle()",rate)
</script>
On this one, where you see the words LETTER are the pics that follow the mouse.
They kinda bunch up a bit. Just tell me if you want another one like more spaced out or whatever.
Smizack
12-21-01, 11:20 AM
<div id="dot0" style="position: absolute; visibility: hidden; height: 11; width: 11;">
<img src="LETTER.gif" height=11 width=11>
</div>
<div id="dot1" style="position: absolute; height: 11; width: 11;">
<img src="LETTER.gif" height=11 width=11>
</div>
<div id="dot2" style="position: absolute; height: 11; width: 11;">
<img src="LETTER.gif" height=11 width=11>
</div>
<div id="dot3" style="position: absolute; height: 11; width: 11;">
<img src="LETTER.gif" height=11 width=11>
</div>
<div id="dot4" style="position: absolute; height: 11; width: 11;">
<img src="LETTER.gif" height=11 width=11>
</div>
<div id="dot5" style="position: absolute; height: 11; width: 11;">
<img src="LETTER.gif" height=11 width=11>
</div>
<div id="dot6" style="position: absolute; height: 11; width: 11;">
<img src="LETTER.gif" height=11 width=11>
</div>
<script LANGUAGE="JavaScript">
<!-- hide code
var nDots = 7;
var Xpos = 0;
var Ypos = 0;
var DELTAT = .01;
var SEGLEN = 10;
var SPRINGK = 10;
var MASS = 1;
var XGRAVITY = 0;
var YGRAVITY = 50;
var RESISTANCE = 10;
var STOPVEL = 0.1;
var STOPACC = 0.1;
var DOTSIZE = 11;var BOUNCE = 0.75;
var isNetscape = navigator.appName=="Netscape";
var followmouse = true;
var dots = new Array();
init();
function init()
{
var i = 0;
for (i = 0; i < nDots; i++) {
dots[i] = new dot(i);
}
if (!isNetscape) {
}
for (i = 0; i < nDots; i++) {
dots[i].obj.left = dots[i].X;
dots[i].obj.top = dots[i].Y;
}
if (isNetscape) {
startanimate();
} else {
setTimeout("startanimate()", 1000);
}
}
function dot(i)
{
this.X = Xpos;
this.Y = Ypos;
this.dx = 0;
this.dy = 0;
if (isNetscape) {
this.obj = eval("document.dot" + i);
} else {
this.obj = eval("dot" + i + ".style");
}
}
function startanimate() {
setInterval("animate()", 20);
}
function setInitPositions(dots)
{
var startloc = document.all.tags("LI");
var i = 0;
for (i = 0; i < startloc.length && i < (nDots - 1); i++) {
dots[i+1].X = startloc[i].offsetLeft
startloc[i].offsetParent.offsetLeft - DOTSIZE;
dots[i+1].Y = startloc[i].offsetTop +
startloc[i].offsetParent.offsetTop + 2*DOTSIZE;
}
dots[0].X = dots[1].X;
dots[0].Y = dots[1].Y - SEGLEN;
}
function MoveHandler(e)
{
Xpos = e.pageX;
Ypos = e.pageY;
return true;
}
function MoveHandlerIE() {
Xpos = window.event.x + document.body.scrollLeft;
Ypos = window.event.y + document.body.scrollTop;
}
if (isNetscape) {
document.captureEvents(Event.MOUSEMOVE);
document.onMouseMove = MoveHandler;
} else {
document.onmousemove = MoveHandlerIE;
}
function vec(X, Y)
{
this.X = X;
this.Y = Y;
}
function springForce(i, j, spring)
{
var dx = (dots[i].X - dots[j].X);
var dy = (dots[i].Y - dots[j].Y);
var len = Math.sqrt(dx*dx + dy*dy);
if (len > SEGLEN) {
var springF = SPRINGK * (len - SEGLEN);
spring.X += (dx / len) * springF;
spring.Y += (dy / len) * springF;
}
}
function animate() {
var start = 0;
if (followmouse) {
dots[0].X = Xpos;
dots[0].Y = Ypos;
start = 1;
}
for (i = start ; i < nDots; i++ ) {
var spring = new vec(0, 0);
if (i > 0) {
springForce(i-1, i, spring);
}
if (i < (nDots - 1)) {
springForce(i+1, i, spring);
}
var resist = new vec(-dots[i].dx * RESISTANCE,
-dots[i].dy * RESISTANCE);
var accel = new vec((spring.X + resist.X)/MASS + XGRAVITY,
(spring.Y + resist.Y)/ MASS + YGRAVITY);
dots[i].dx += (DELTAT * accel.X);
dots[i].dy += (DELTAT * accel.Y);
if (Math.abs(dots[i].dx) < STOPVEL &&
Math.abs(dots[i].dy) < STOPVEL &&
Math.abs(accel.X) < STOPACC &&
Math.abs(accel.Y) < STOPACC) {
dots[i].dx = 0;
dots[i].dy = 0;
}
dots[i].X += dots[i].dx;
dots[i].Y += dots[i].dy;
var height, width;
if (isNetscape) {
height = window.innerHeight + window.pageYOffset;
width = window.innerWidth + window.pageXOffset;
} else {
height = document.body.clientHeight + document.body.scrollTop;
width = document.body.clientWidth + document.body.scrollLeft;
}
if (dots[i].Y >= height - DOTSIZE - 1) {
if (dots[i].dy > 0) {
dots[i].dy = BOUNCE * -dots[i].dy;
}
dots[i].Y = height - DOTSIZE - 1;
}
if (dots[i].X >= width - DOTSIZE) {
if (dots[i].dx > 0) {
dots[i].dx = BOUNCE * -dots[i].dx;
}
dots[i].X = width - DOTSIZE - 1;
}
if (dots[i].X < 0) {
if (dots[i].dx < 0) {
dots[i].dx = BOUNCE * -dots[i].dx;
}
dots[i].X = 0;
}
dots[i].obj.left = dots[i].X;
dots[i].obj.top = dots[i].Y;
}
}
// end code hiding -->
</script>
Ok, One more. This one has 6 places for a gif currently. If you want to add or remove letter places just add/delte this:
</div>
<div id="dot0" style="position: absolute; height: 11; width: 11;">
<img src="LETTER.gif" height=11 width=11>
This script makes the letters kinda bouncy and all seperated.
Smizack
12-22-01, 03:18 AM
*bump
Making sure you get this...
Okay now post the code that is two times as long....just for the sake of netscape 6.+ users...oh wait...there are none...j/k
Smizack
12-22-01, 10:29 PM
Originally posted by turok
Okay now post the code that is two times as long....just for the sake of netscape 6.+ users...oh wait...there are none...j/k
Uhhh.. yeah. I'll get right on that. But you know, trying to compress html code isn't that easy...
*bump again for USA
Smizack
These codes don't work for OE6
Smizack
12-24-01, 12:10 PM
Originally posted by USA
Smizack
These codes don't work for OE6
I'll have to look for that. I don't konw jack aboot outlook. They'll work for your web page though.
Smizack
12-28-01, 10:15 AM
Originally posted by USA
What about OE6
Hmmm.. OE6 for dummies mabey?
I don't know man, I looked at it a bit. I can't find anyone else's code for that either.
i'll keep looking though.
UnseenMenace
12-28-01, 10:21 AM
Does'nt Outlook Express 6 block scripts by default ?
UnseenMenace
12-28-01, 10:27 AM
**** Thread Moved to Programming Tips and Tricks ****
Please try to post in the correct topic area. HTML and Javascript are basic languages
UnseenMenace - Forum Moderator
vBulletin® v3.8.7, Copyright ©2000-2012, vBulletin Solutions, Inc.