We can make text to move along the mouse using javascript as given below,
<html>
<head>
<style>
.spanstyle
{
position:absolute;
visibility:visible;
top:-50px;
font-size:10pt;
font-family:Verdana;
font-weight:bold;
color:black;
}
</style>
<script>
var x,y
var step=20
var flag=0
var text='Syncfusion .NET Essentials '
text=text.split('')
var xpos=new Array()
for (i=0;i<=text.length-1;i++)
{
xpos[i]=-50
}
var ypos=new Array()
for (i=0;i<=text.length-1;i++)
{
ypos[i]=-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 MoveText()
{
if (flag==1 && document.all)
{
for (i=text.length-1; i>=1; i--)
{
xpos[i]=xpos[i-1]+step
ypos[i]=ypos[i-1]
}
xpos[0]=x+step
ypos[0]=y
for (i=0; i<text.length-1; i++)="" {="" var="" spanvalue="eval('span'+(i)+'.style')" spanvalue.posleft="xpos[i]" spanvalue.postop="ypos[i]" }="" else="" if="" (flag="=1" &&="" document.layers)="" for="" (i="text.length-1;" i="">=1; i--)
{
xpos[i]=xpos[i-1]+step
ypos[i]=ypos[i-1]
}
xpos[0]=x+step
ypos[0]=y
for (i=0; i<text.length-1; i++)="" {="" var="" spanvalue="eval('document.span'+i)" spanvalue.left="xpos[i]" spanvalue.top="ypos[i]" }="" timer="setTimeout('MoveText()',30)" <="" script>="" head>="" <body="" onload="MoveText()" style="width:100%;overflow-x:hidden;overflow-y:scroll" >="" <script>="" for="" (i="0;i<=text.length-1;i++)" document.write('<span="" id="’span'+i+'’" class="’spanstyle’">')
document.write(text[i])
document.write('')
}
if (document.layers)
{
document.captureEvents(Event.MOUSEMOVE);
}
document.onmousemove = handlerMM;
</script>
</body>
</html>
</text.length-1;></text.length-1;>
Share with