Búsqueda en el Foro:
Buscar


Autor Mensaje
Mensaje25-09-2008, 19:51 (UTC)    
Título del mensaje: [Código Javascript] Cursores

Estrella persiguiendo al puntero:

Código:
<!-- Dentro del Tag HEAD -->

<STYLE TYPE="text/css">
<!--

BODY{
overflow:scroll;
overflow-x:hidden;
}

.s1
{
  position  : absolute;
  font-size : 10pt;
  color     : blue;
  visibility: hidden;
}

.s2
{
  position  : absolute;
  font-size : 18pt;
  color     : red;
   visibility : hidden;
}

.s3
{
  position  : absolute;
  font-size : 14pt;
  color     : gold;
   visibility : hidden;
}

.s4
{
  position  : absolute;
  font-size : 12pt;
  color     : lime;
   visibility : hidden;
}

//-->
</STYLE>


<!-- Dentro del Tag BODY -->

<DIV ID="div1" CLASS="s1">*</DIV>
<DIV ID="div2" CLASS="s2">*</DIV>
<DIV ID="div3" CLASS="s3">*</DIV>
<DIV ID="div4" CLASS="s4">*</DIV>


<SCRIPT LANGUAGE="javascript" TYPE="text/javascript">

// adaptado por http://www.losrecursosgratis.com

var nav = (document.layers);
var tmr = null;
var spd = 50;
var x = 0;
var x_offset = 5;
var y = 0;
var y_offset = 15;

if(nav) document.captureEvents(Event.MOUSEMOVE);
document.onmousemove = get_mouse;

function get_mouse(e)
{   
  x = (nav) ? e.pageX : event.clientX+document.body.scrollLeft;
  y = (nav) ? e.pageY : event.clientY+document.body.scrollTop;
  x += x_offset;
  y += y_offset;
  beam(1);     
}

function beam(n)
{
  if(n<5)
  {
    if(nav)
    {
      eval("document.div"+n+".top="+y);
      eval("document.div"+n+".left="+x);
      eval("document.div"+n+".visibility='visible'");
    } 
    else
    {
      eval("div"+n+".style.top="+y);
      eval("div"+n+".style.left="+x);
      eval("div"+n+".style.visibility='visible'");
    }
    n++;
    tmr=setTimeout("beam("+n+")",spd);
  }
  else
  {
     clearTimeout(tmr);
     fade(4);
  }   
}

function fade(n)
{
  if(n>0)
  {
    if(nav)eval("document.div"+n+".visibility='hidden'");
    else eval("div"+n+".style.visibility='hidden'");
    n--;
    tmr=setTimeout("fade("+n+")",spd);
  }
  else clearTimeout(tmr);
}

// -->
</SCRIPT>


ejemplo: http://www.losrecursosgratis.com/javascript/ejemplos/punteroestrella.htm



Conjunto de estrellas persiguiendo el cursor:

Código:
<LAYER NAME="a0" LEFT=10 TOP=10 VISIBILITY=SHOW BGCOLOR="#ffffff" CLIP="0,0,1,1"></LAYER>
<LAYER NAME="a1" LEFT=10 TOP=10 VISIBILITY=SHOW BGCOLOR="#fff000" CLIP="0,0,1,1"></LAYER>
<LAYER NAME="a2" LEFT=10 TOP=10 VISIBILITY=SHOW BGCOLOR="#ffa000" CLIP="0,0,1,1"></LAYER>
<LAYER NAME="a3" LEFT=10 TOP=10 VISIBILITY=SHOW BGCOLOR="#ff00ff" CLIP="0,0,1,1"></LAYER>
<LAYER NAME="a4" LEFT=10 TOP=10 VISIBILITY=SHOW BGCOLOR="#00ff00" CLIP="0,0,1,1"></LAYER>
<LAYER NAME="a5" LEFT=10 TOP=10 VISIBILITY=SHOW BGCOLOR="#FF00FF" CLIP="0,0,1,1"></LAYER>
<LAYER NAME="a6" LEFT=10 TOP=10 VISIBILITY=SHOW BGCOLOR="#FF0000" CLIP="0,0,1,1"></LAYER>
<LAYER NAME="a7" LEFT=10 TOP=10 VISIBILITY=SHOW BGCOLOR="#ffffff" CLIP="0,0,2,2"></LAYER>
<LAYER NAME="a8" LEFT=10 TOP=10 VISIBILITY=SHOW BGCOLOR="#fff000" CLIP="0,0,2,2"></LAYER>
<LAYER NAME="a9" LEFT=10 TOP=10 VISIBILITY=SHOW BGCOLOR="#ffa000" CLIP="0,0,2,2"></LAYER>
<LAYER NAME="a10" LEFT=10 TOP=10 VISIBILITY=SHOW BGCOLOR="#ff00ff" CLIP="0,0,2,2"></LAYER>
<LAYER NAME="a11" LEFT=10 TOP=10 VISIBILITY=SHOW BGCOLOR="#00ff00" CLIP="0,0,2,2"></LAYER>
<LAYER NAME="a12" LEFT=10 TOP=10 VISIBILITY=SHOW BGCOLOR="#0000ff" CLIP="0,0,2,2"></LAYER>
<LAYER NAME="a13" LEFT=10 TOP=10 VISIBILITY=SHOW BGCOLOR="#FF0000" CLIP="0,0,3,3"></LAYER>


<script language="JavaScript">

/*
Magic Wand cursor (By Kurt at kurt.grigg@virgin.net)
Modified and permission granted to Dynamic Drive to feature script in archive
For full source, usage terms, and 100's more DHTML scripts, visit http://dynamicdrive.com
*/

if (document.all){
with (document){
write('<div id="starsDiv" style="position:absolute;top:0px;left:0px">')
write('<div style="position:relative;width:1px;height:1px;background:#ffffff;font-size:1px;visibility:visible"></div>')
write('<div style="position:relative;width:1px;height:1px;background:#fff000;font-size:1px;visibility:visible"></div>')
write('<div style="position:relative;width:1px;height:1px;background:#ffa000;font-size:1px;visibility:visible"></div>')
write('<div style="position:relative;width:1px;height:1px;background:#ff00ff;font-size:1px;visibility:visible"></div>')
write('<div style="position:relative;width:1px;height:1px;background:#00ff00;font-size:1px;visibility:visible"></div>')
write('<div style="position:relative;width:1px;height:1px;background:#0000ff;font-size:1px;visibility:visible"></div>')
write('<div style="position:relative;width:1px;height:1px;background:#FF0000;font-size:1px;visibility:visible"></div>')
write('<div style="position:relative;width:2px;height:2px;background:#ffffff;font-size:2px;visibility:visible"></div>')
write('<div style="position:relative;width:2px;height:2px;background:#fff000;font-size:2px;visibility:visible"></div>')
write('<div style="position:relative;width:2px;height:2px;background:#ffa000;font-size:2px;visibility:visible"></div>')
write('<div style="position:relative;width:2px;height:2px;background:#ff00ff;font-size:2px;visibility:visible"></div>')
write('<div style="position:relative;width:2px;height:2px;background:#00ff00;font-size:2px;visibility:visible"></div>')
write('<div style="position:relative;width:2px;height:2px;background:#0000ff;font-size:2px;visibility:visible"></div>')
write('<div style="position:relative;width:3px;height:3px;background:#FF0000;font-size:3px;visibility:visible"></div>')
write('</div>')
}
}


var Clrs=new Array(6)
Clrs[0]='ff0000';
Clrs[1]='00ff00';
Clrs[2]='000aff';
Clrs[3]='ff00ff';
Clrs[4]='fff000';
Clrs[5]='fffff0';



if (document.layers)
{window.captureEvents(Event.MOUSEMOVE);}
var yBase = 200;
var xBase = 200;
var step;
var currStep = 0;
var Xpos = 1;
var Ypos = 1;

if (document.all)
{
  function MoveHandler(){
  Xpos = document.body.scrollLeft+event.x;
  Ypos = document.body.scrollTop+event.y;
  }
  document.onmousemove = MoveHandler;
}

else if (document.layers)
{
  function xMoveHandler(evnt){
  Xpos = evnt.pageX;
  Ypos = evnt.pageY;
  }
  window.onMouseMove = xMoveHandler;
}

function animateLogo() {
if (document.all)
{
 yBase = window.document.body.offsetHeight/4;
 xBase = window.document.body.offsetWidth/4;
}
else if (document.layers)
{
 yBase = window.innerHeight/4;
 xBase = window.innerWidth/4;
}

if (document.all)
{
 for ( i = 0 ; i < starsDiv.all.length ; i++ )
 {step=3;
  starsDiv.all[i].style.top = Ypos + yBase*Math.cos((currStep + i*4)/12)*Math.cos(0.7+currStep/200);
  starsDiv.all[i].style.left = Xpos + xBase*Math.sin((currStep + i*3)/10)*Math.sin(8.2+currStep/400);
  for (ai=0; ai < Clrs.length; ai++)
    {
     var c=Math.round(Math.random()*[ai]);
    }
    starsDiv.all[i].style.background=Clrs[c];
 }
}

else if (document.layers)
{
 for ( j = 0 ; j < 14 ; j++ ) //number of NS layers!
 {step = 4;
  var templayer="a"+j
  document.layers[templayer].top = Ypos + yBase*Math.sin((currStep + j*4)/12)*Math.cos(0.7+currStep/200);
  document.layers[templayer].left = Xpos + xBase*Math.sin((currStep + j*3)/10)*Math.sin(8.2+currStep/400);
  for (aj=0; aj < Clrs.length; aj++)
    {
     var c=Math.round(Math.random()*[aj]);
    }
    document.layers[templayer].bgColor=Clrs[c];
 }
}
currStep+= step;
setTimeout("animateLogo()", 10);
}
animateLogo();
// -->
</script>
Código:
<!-- Mas trucos y scripts en http://www.javascript.com.mx -->
<STYLE>
v\:* {
 BEHAVIOR: url(#default#VML)
}
</STYLE>
 
<SCRIPT>
// CREDITS:
// Spider Highlighter for Textlinks
// by Urs Dudli and Peter Gehrig
// Copyright (c) 2001 Peter Gehrig and Urs Dudli. All rights reserved.
// Permission given to use the script provided that this notice remains as is.
// Additional scripts can be found at http://www.24fun.com
// info@24fun.com
// 11/6/2001

// IMPORTANT:
// If you add this script to a script-library or a script-archive
// you are required to insert a highly visible link to http://www.24fun.com
// right into the webpage where the script
// will be displayed.

///////////////////////////////////////////////////////////////////////////
// CONFIGURATION STARTS HERE
///////////////////////////////////////////////////////////////////////////

// the default color of the 8 spiderlines
var defaultcolor="#F5F5F5"

// the width of the 8 spiderlines while highlighting textlinks (pixels)
var lineweighthighlight=50

// the width of the 8 spiderlines while NOT highlighting textlinks (pixels)
var lineweightnormal=2

///////////////////////////////////////////////////////////////////////////
// CONFIGURATION ENDS HERE
///////////////////////////////////////////////////////////////////////////

var distancetomouse=0

var mousepos_x=0
var mousepos_x=0

var marginleft=0
var margintop=0
var marginbottom=0
var marginright=0

var margincenterx
var margincentery

var mousepos_x=0
var mousepos_x=0

if (document.all&&window.print){
    document.write('<div id="bodycontent" style="position:relative">')
}

function initiateanimation(){

    marginbottom=document.body.clientHeight
    marginright=document.body.clientWidth
    margincenterx=Math.floor(marginright/2)
    margincentery=Math.floor(marginbottom/2)
   
    rectangulartopleft.to=marginleft+","+margintop
    rectangulartopright.to=marginright+","+margintop
    rectangularbottomleft.to=marginleft+","+marginbottom
    rectangularbottomright.to=marginright+","+marginbottom
   
    rectangulartop.to=margincenterx+","+margintop
    rectangularright.to=marginright+","+margincentery
    rectangularbottom.to=margincenterx+","+marginbottom
    rectangularleft.to=marginleft+","+margincentery
   
    rectangulartopleft.strokecolor=defaultcolor
    rectangulartopright.strokecolor=defaultcolor
    rectangularbottomleft.strokecolor=defaultcolor
    rectangularbottomright.strokecolor=defaultcolor
   
    rectangulartop.strokecolor=defaultcolor
    rectangularright.strokecolor=defaultcolor
    rectangularbottom.strokecolor=defaultcolor
    rectangularleft.strokecolor=defaultcolor
}

function msover(thiscolorhighlight){
    if(document.all&&window.print){
        rectangulartopleft.strokecolor=thiscolorhighlight
        rectangulartopright.strokecolor=thiscolorhighlight
        rectangularbottomleft.strokecolor=thiscolorhighlight
        rectangularbottomright.strokecolor=thiscolorhighlight
   
        rectangulartop.strokecolor=thiscolorhighlight
        rectangularright.strokecolor=thiscolorhighlight
        rectangularbottom.strokecolor=thiscolorhighlight
        rectangularleft.strokecolor=thiscolorhighlight
       
        rectangulartopleft.strokeweight=lineweighthighlight
        rectangulartopright.strokeweight=lineweighthighlight
        rectangularbottomleft.strokeweight=lineweighthighlight
        rectangularbottomright.strokeweight=lineweighthighlight
   
        rectangulartop.strokeweight=lineweighthighlight
        rectangularright.strokeweight=lineweighthighlight
        rectangularbottom.strokeweight=lineweighthighlight
        rectangularleft.strokeweight=lineweighthighlight
    }
}

function msout(){
    if(document.all&&window.print){
        rectangulartopleft.strokecolor=defaultcolor
        rectangulartopright.strokecolor=defaultcolor
        rectangularbottomleft.strokecolor=defaultcolor
        rectangularbottomright.strokecolor=defaultcolor
   
        rectangulartop.strokecolor=defaultcolor
        rectangularright.strokecolor=defaultcolor
        rectangularbottom.strokecolor=defaultcolor
        rectangularleft.strokecolor=defaultcolor
       
        rectangulartopleft.strokeweight=lineweightnormal
        rectangulartopright.strokeweight=lineweightnormal
        rectangularbottomleft.strokeweight=lineweightnormal
        rectangularbottomright.strokeweight=lineweightnormal
   
        rectangulartop.strokeweight=lineweightnormal
        rectangularright.strokeweight=lineweightnormal
        rectangularbottom.strokeweight=lineweightnormal
        rectangularleft.strokeweight=lineweightnormal     
    }
}


function momouse(){
    if(document.all&&window.print){
        mousepos_x=document.body.scrollLeft+event.clientX
        mousepos_y=document.body.scrollTop+event.clientY
   
        rectangulartopleft.from=mousepos_x+","+mousepos_y
        rectangulartopright.from=mousepos_x+","+mousepos_y
        rectangularbottomleft.from=mousepos_x+","+mousepos_y
        rectangularbottomright.from=mousepos_x+","+mousepos_y
   
        rectangulartop.from=mousepos_x+","+mousepos_y
        rectangularright.from=mousepos_x+","+mousepos_y
        rectangularbottom.from=mousepos_x+","+mousepos_y
        rectangularleft.from=mousepos_x+","+mousepos_y
     }
}

if(document.all&&window.print){
    code="<v:line id=rectangulartopleft style='LEFT:0;POSITION:absolute;TOP:0;' strokeweight='"+lineweightnormal+"pt'></v:line>"
    code+="<v:line id=rectangulartopright style='LEFT:0;POSITION:absolute;TOP:0;' strokeweight='"+lineweightnormal+"pt'></v:line>"
    code+="<v:line id=rectangularbottomleft style='LEFT:0;POSITION:absolute;TOP:0;' strokeweight='"+lineweightnormal+"pt'></v:line>"
    code+="<v:line id=rectangularbottomright style='LEFT:0;POSITION:absolute;TOP:0;' strokeweight='"+lineweightnormal+"pt'></v:line>"

    code+="<v:line id=rectangulartop style='LEFT:0;POSITION:absolute;TOP:0;' strokeweight='"+lineweightnormal+"pt'></v:line>"
    code+="<v:line id=rectangularright style='LEFT:0;POSITION:absolute;TOP:0;' strokeweight='"+lineweightnormal+"pt'></v:line>"
    code+="<v:line id=rectangularbottom style='LEFT:0;POSITION:absolute;TOP:0;' strokeweight='"+lineweightnormal+"pt'></v:line>"
    code+="<v:line id=rectangularleft style='LEFT:0;POSITION:absolute;TOP:0;' strokeweight='"+lineweightnormal+"pt'></v:line>"

    document.body.insertAdjacentHTML("afterBegin",code)
    document.onmousemove=momouse
    window.onload=initiateanimation
}
</SCRIPT>
Código:
<!-- Mas trucos y scripts en http://www.javascript.com.mx -->
<LAYER NAME="a0" LEFT=10 TOP=10 VISIBILITY=SHOW BGCOLOR="#0098f0" CLIP="0,0,1,1"></LAYER>
<LAYER NAME="a1" LEFT=10 TOP=10 VISIBILITY=SHOW BGCOLOR="#0098f0" CLIP="0,0,1,1"></LAYER>
<LAYER NAME="a2" LEFT=10 TOP=10 VISIBILITY=SHOW BGCOLOR="#0098f0" CLIP="0,0,1,1"></LAYER>
<LAYER NAME="a3" LEFT=10 TOP=10 VISIBILITY=SHOW BGCOLOR="#0098f0" CLIP="0,0,1,1"></LAYER>
<LAYER NAME="a4" LEFT=10 TOP=10 VISIBILITY=SHOW BGCOLOR="#0098f0" CLIP="0,0,1,1"></LAYER>
<LAYER NAME="a5" LEFT=10 TOP=10 VISIBILITY=SHOW BGCOLOR="#0098f0" CLIP="0,0,1,1"></LAYER>
<LAYER NAME="a6" LEFT=10 TOP=10 VISIBILITY=SHOW BGCOLOR="#0098f0" CLIP="0,0,1,1"></LAYER>
<LAYER NAME="a7" LEFT=10 TOP=10 VISIBILITY=SHOW BGCOLOR="#0098f0" CLIP="0,0,2,2"></LAYER>
<LAYER NAME="a8" LEFT=10 TOP=10 VISIBILITY=SHOW BGCOLOR="#0098f0" CLIP="0,0,2,2"></LAYER>
<LAYER NAME="a9" LEFT=10 TOP=10 VISIBILITY=SHOW BGCOLOR="#0098f0" CLIP="0,0,2,2"></LAYER>
<LAYER NAME="a10" LEFT=10 TOP=10 VISIBILITY=SHOW BGCOLOR="#0098f0" CLIP="0,0,2,2"></LAYER>
<LAYER NAME="a11" LEFT=10 TOP=10 VISIBILITY=SHOW BGCOLOR="#0098f0" CLIP="0,0,2,2"></LAYER>
<LAYER NAME="a12" LEFT=10 TOP=10 VISIBILITY=SHOW BGCOLOR="#0098f0" CLIP="0,0,2,2"></LAYER>
<LAYER NAME="a13" LEFT=10 TOP=10 VISIBILITY=SHOW BGCOLOR="#0098f0" CLIP="0,0,3,3"></LAYER>
<div id="starsDiv" style="position:absolute;top:0px;left:0px">
<div style="position:relative;width:7px;height:7px;background:#0098f0;font-size:7px;visibility:visible"></div>
<div style="position:relative;width:7px;height:7px;background:#0098f0;font-size:7px;visibility:visible"></div>
<div style="position:relative;width:7px;height:7px;background:#0098f0;font-size:7px;visibility:visible"></div>
<div style="position:relative;width:7px;height:7px;background:#0098f0;font-size:7px;visibility:visible"></div>
<div style="position:relative;width:7px;height:7px;background:#0098f0;font-size:7px;visibility:visible"></div>
<div style="position:relative;width:7px;height:7px;background:#0098f0;font-size:7px;visibility:visible"></div>
<div style="position:relative;width:7px;height:7px;background:#0098f0;font-size:7px;visibility:visible"></div>
<div style="position:relative;width:8px;height:8px;background:#0098f0;font-size:8px;visibility:visible"></div>
<div style="position:relative;width:8px;height:8px;background:#0098f0;font-size:8px;visibility:visible"></div>
<div style="position:relative;width:8px;height:8px;background:#0098f0;font-size:8px;visibility:visible"></div>
<div style="position:relative;width:8px;height:8px;background:#0098f0;font-size:8px;visibility:visible"></div>
<div style="position:relative;width:8px;height:8px;background:#0098f0;font-size:8px;visibility:visible"></div>
<div style="position:relative;width:8px;height:8px;background:#0098f0;font-size:8px;visibility:visible"></div>
<div style="position:relative;width:9px;height:9px;background:#0098f0;font-size:9px;visibility:visible"></div>
</div>


<SCRIPT LANGUAGE="JavaScript">

var Clrs = new Array(6);
Clrs[0] = '0098f0';
Clrs[1] = '0098f0';
Clrs[2] = '0098f0';
Clrs[3] = '0098f0';
Clrs[4] = '0098f0';
Clrs[5] = '0098f0';
var yBase = 200;
var xBase = 200;
var step;
var currStep = 0;
var Xpos = 1;
var Ypos = 1;
var Xs = 200;
var Ys = 400;
if (document.layers) {
window.captureEvents(Event.MOUSEMOVE);
}
if (document.all) {
function MoveHandler() {
Xpos = document.body.scrollLeft+event.x;
Ypos = document.body.scrollTop+event.y;
}
document.onmousemove = MoveHandler;
}
else if (document.layers) {
function xMoveHandler(evnt) {
Xpos = evnt.pageX;
Ypos = evnt.pageY;
}
window.onMouseMove = xMoveHandler;
}
function Comet() {
if (document.all) {
yBase = window.document.body.offsetHeight / 4;
xBase = window.document.body.offsetWidth / 4;
}
else if (document.layers) {
yBase = window.innerHeight / 4;
xBase = window.innerWidth / 4;
}
if (document.all) {
for ( i = 0 ; i < starsDiv.all.length ; i++ ) {
step = 3;
starsDiv.all[i].style.top = Ypos + yBase*Math.cos((currStep + i*4)/12)*Math.cos(0.7+currStep/200);
starsDiv.all[i].style.left = Xpos + xBase*Math.sin((currStep + i*3)/10)*Math.sin(8.2+currStep/400);
for (ai = 0; ai < Clrs.length; ai++) {
var c=Math.round(Math.random()*[ai]);
}
starsDiv.all[i].style.background = Clrs[c];
   }
}
else if (document.layers) {
for ( j = 0 ; j < 14 ; j++ ) { //number of NS layers!
step = 6;
var templayer = "a"+j;
document.layers[templayer].top = Ypos + yBase*Math.cos((currStep + j*4)/12)*Math.cos(0.7+currStep/200);
document.layers[templayer].left = Xpos + xBase*Math.sin((currStep + j*3)/10)*Math.sin(8.2+currStep/400);
for (aj=0; aj < Clrs.length; aj++)
{
 var c=Math.round(Math.random()*[aj]);
}
document.layers[templayer].bgColor = Clrs[c];
   }
}
currStep += step;
setTimeout("Comet()", 45);
}
Comet();

</script>
Código:
<!-- Mas trucos y scripts en http://www.javascript.com.mx -->    
<style type="text/css">

.ant {
height: 16px;
position: absolute;
visibility: hidden;
width: 16px;
}

</style>
<script language="JavaScript" src="dhtmllib.js">

</script>
<script language="JavaScript">
var myimages=new Array()
function preloadimages(){
for (i=0;i<preloadimages.arguments.length;i++){
myimages[i]=new Image()
myimages[i].src=preloadimages.arguments[i]
}
}
preloadimages("antdl.gif",
"antdn.gif",
"antdr.gif",
"antlt.gif",
"antrt.gif",
"antul.gif",
"antup.gif",
"antur.gif");


// These variables will hold the current mouse pointer position.

var mouseX = 0;
var mouseY = 0;

// Set up event capturing.

if (isMinNS4)
document.captureEvents(Event.MOUSEMOVE);
document.onmousemove = getMousePosition;

function init() {

// Start loading images.

//startLoadBar(images);
endLoadBar()
}

function getMousePosition(e) {

// Save cursor position using browser-specific code.

if (isMinNS4) {
mouseX = e.pageX;
mouseY = e.pageY;
}
if (isMinIE4) {
mouseX = event.clientX + document.body.scrollLeft;
mouseY = event.clientY + document.body.scrollTop;
}
return true;
}

var ants = new Array(8);

function endLoadBar() {

var i;

// Get handles to all the ant layers.

for (i = 0; i < ants.length; i++) {
ants[i] = getLayer("ant" + (i + 1));
if (isMinNS4)
ants[i].image = ants[i].document.images["antimg" + (i + 1)];
if (isMinIE4)
ants[i].image = document.images["antimg" + (i + 1)];
initAnt(i);
showLayer(ants[i]);
}
updateAnts();
}

function initAnt(n) {

var s, x, y;

// Randomly place an ant on the window.

x = Math.floor(Math.random() * getWindowWidth());
y = Math.floor(Math.random() * getWindowHeight());
s = Math.floor(Math.random() * 4);
if (s == 0)
x = -getWidth(ants[n]);
if (s == 1)
x = getWindowWidth();
if (s == 2)
y = -getHeight(ants[n]);
if (s == 3)
y = getWindowHeight();
x += getPageScrollX();
y += getPageScrollY();
moveLayerTo(ants[n], x, y);
}

function updateAnts() {

var i, dx, dy, theta, d;

// Move each ant toward the mouse pointer, if she hits it, drop her back onto
// the page randomly.

d = 3;
for (i = 0; i < ants.length; i++) {

// Find the angle between the ant and the pointer.

dx = mouseX - getLeft(ants[i]);
dy = mouseY - getTop(ants[i]);
theta = Math.round(Math.atan2(-dy, dx) * 180 / Math.PI);
if (theta < 0)
theta += 360;

// Hit the pointer?

if (Math.abs(dx) < d && Math.abs(dy) < d)
initAnt(i);

// If not, move the ant and set the image based on angle.

else if (theta > 23 && theta <= 68) {
moveLayerBy(ants[i], d, -d);
ants[i].image.src = "antur.gif";
}
else if (theta > 68 && theta <= 113) {
moveLayerBy(ants[i], 0, -d);
ants[i].image.src = "antup.gif";
}
else if (theta > 113 && theta <= 158) {
moveLayerBy(ants[i], -d, -d);
ants[i].image.src = "antul.gif";
}
else if (theta > 158 && theta <= 203) {
moveLayerBy(ants[i], -d, 0);
ants[i].image.src = "antlt.gif";
}
else if (theta > 203 && theta <= 248) {
moveLayerBy(ants[i], -d, d);
ants[i].image.src = "antdl.gif";
}
else if (theta > 248 && theta <= 293) {
moveLayerBy(ants[i], 0, d);
ants[i].image.src = "antdn.gif";
}
else if (theta > 293 && theta <= 338) {
moveLayerBy(ants[i], d, d);
ants[i].image.src = "antdr.gif";
}
else {
moveLayerBy(ants[i], d, 0);
ants[i].image.src = "antrt.gif";
}
}

// Set up next call.

setTimeout('updateAnts()', 50);
return;
}

</script>


ejemplo: http://www.javascript.com.mx/javascripts/efectos-cursores/cursor28.html


Extraterrestres atacan el cursor (luego de unos segundos):

Código:
<!-- Mas trucos y scripts en http://www.javascript.com.mx -->
<script language="JavaScript" src="mouse-invaders.js"></script>


ejemplo: http://www.javascript.com.mx/javascripts/efectos-cursores/cursor25.html


Burbujas en el cursor: (utilizar esta imagen

Código:
<!-- Mas trucos y scripts en http://www.javascript.com.mx -->
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
Image0 = new Image();
Image0.src = "bubblue.gif";
Amount = 20;
Ymouse = -50;
Xmouse = -50;
Ypos = new Array();
Xpos = new Array();
Speed = new Array();
rate = new Array();
grow = new Array();
Step = new Array();
Cstep = new Array();
nsSize = new Array();
ns = (document.layers)?1:0;
(document.layers)?window.captureEvents(Event.MOUSEMOVE):0;
function Mouse(evnt) {
Ymouse=(document.layers)?evnt.pageY-20:event.y-20;
Xmouse=(document.layers)?evnt.pageX:event.x;
}
(document.layers)?window.onMouseMove=Mouse:document.onmousemove=Mouse;
for (i = 0; i < Amount; i++) {
Ypos[i] = Ymouse;
Xpos[i] = Xmouse;
Speed[i] = Math.random()*4+1;
Cstep[i] = 0;
Step[i] = Math.random()*0.1+0.05;
grow[i] = 8;
nsSize[i] = Math.random()*15+5;
rate[i] = Math.random()*0.5+0.1;
}
if (ns) {
for (i = 0; i < Amount; i++) {
document.write("<LAYER NAME='sn"+i+"' LEFT=0 TOP=0><img src="+Image0.src+" name='N' width="+nsSize[i]+" height="+nsSize[i]+"></LAYER>");
   }
}
else {
document.write('<div style="position:absolute;top:0px;left:0px"><div style="position:relative">');
for (i = 0; i < Amount; i++) {
document.write('<img id="si" src="'+Image0.src+'" style="position:absolute;top:0px;left:0px;filter:alpha(opacity=90)">');
}
document.write('</div></div>');
}
function MouseBubbles() {
var hscrll = (document.layers)?window.pageYOffset:document.body.scrollTop;
var wscrll = (document.layers)?window.pageXOffset:document.body.scrollLeft;
for (i = 0; i < Amount; i++){
sy = Speed[i] * Math.sin(270 * Math.PI / 180);
sx = Speed[i] * Math.cos(Cstep[i] * 4);
Ypos[i] += sy;
Xpos[i] += sx;
if (Ypos[i] < -40) {
Ypos[i] = Ymouse;
Xpos[i] = Xmouse;
Speed[i] = Math.random() * 6 + 4;
grow[i] = 8;
nsSize[i] = Math.random() * 15 + 5;
}
if (ns) {
document.layers['sn'+i].left = Xpos[i] + wscrll;
document.layers['sn'+i].top = Ypos[i] + hscrll;
}
else {
si[i].style.pixelLeft = Xpos[i] + wscrll;
si[i].style.pixelTop = Ypos[i] + hscrll;
si[i].style.width = grow[i];
si[i].style.height = grow[i];
}
grow[i] += rate[i];
Cstep[i] += Step[i];
if (grow[i] > 24) grow[i] = 25;
}
setTimeout('MouseBubbles()', 10);
}
MouseBubbles();
//  End -->
</script>
Código:
<!-- Mas trucos y scripts en http://www.javascript.com.mx -->
<div id="dot0" style="position: absolute; visibility: hidden; height: 11; width: 11;">
<dd><img src="bullet.gif" height="11" width="11"></dd>
</div><div id="dot1" style="position: absolute; height: 11; width: 11;">
<dd><img src="bullet.gif" height="11" width="11"></dd>
</div><div id="dot2" style="position: absolute; height: 11; width: 11;">
<dd><img src="bullet.gif" height="11" width="11"></dd>
</div><div id="dot3" style="position: absolute; height: 11; width: 11;">
<dd><img src="bullet.gif" height="11" width="11"></dd>
</div><div id="dot4" style="position: absolute; height: 11; width: 11;">
<dd><img src="bullet.gif" height="11" width="11"></dd>
</div><div id="dot5" style="position: absolute; height: 11; width: 11;">
<dd><img src="bullet.gif" height="11" width="11"></dd>
</div><div id="dot6" style="position: absolute; height: 11; width: 11;">
<dd><img src="bullet.gif" height="11" width="11"></dd>
</div><script LANGUAGE="JavaScript">
<!--

var nDots = 7;
if (document.all&&window.print)
document.body.style.cssText="overflow-x:hidden;overflow-y:scroll"
var Xpos = 0;
var Ypos = 0;
var DELTAT = .01;
var SEGLEN = 10;
var SPRINGK = 10;
var MASS = 1;
var GRAVITY = 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()", 2000);
    }
}



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,
            (spring.Y + resist.Y)/ MASS + GRAVITY);
       
        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 + document.scrollTop;
            width = window.innerWidth + document.scrollLeft;
        } 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;      
    }
}

// -->
</script>


puedes eleger la imagen que quieres solo busca la imagen de tamaño 11 x 11 pixeles y la url la colocas cada ves que dice <img src

ejemplo: http://www.javascript.com.mx/javascripts/efectos-cursores/cursor14.html


no son muchos pero alguno les puede servir

saludoss....
______________
LO MAXIMO EN SMILEYS PARA MSN


Ultima edición por tus-emoticones el Lun Oct 13, 2008 12:39 am; editado 1 vez
Mensaje03-10-2008, 12:59 (UTC)    
Título del mensaje:

a mi no me funciono niguno
______________

Plantillas | CSS | HTML | Normas del foro | Contacto | Tutoriales
Mail de ayuda: contacto@radioflash.com

Mensaje03-10-2008, 16:14 (UTC)    
Título del mensaje:

radioflash24 escribió:
a mi no me funciono niguno



Es depende qué navegador uses,en el Mozilla Firefox muchas veces no funcionan estos tipos de códigos.
______________
Estoy al borde de la gloria, y estoy colgando de un momento de verdad,
estoy al borde la gloria Y estoy suspendida de un momento junto a tí

Mensaje03-10-2008, 18:40 (UTC)    
Título del mensaje:

el post es de cursores y todos los codigos de ursores y la mayoria de efectos solo funcionan con internet explorer
saludos
Mostrar mensajes anteriores:   


Powered by phpBB © 2001, 2005 phpBB Group