Other Song

English Song

鼠标效果(mouse effect)


美吧?想学怎么做吗?很简单,也是拷贝和黏贴代码罢了。

首先,去layout--->edit html
First, go to layout ---> edit html

在<head>和</head>之间贴入以下的代码
Paste the code below under <head>

<script type="text/javascript">
// <![CDATA[
var colour="#666666";
var sparkles=40;

var x=ox=400;
var y=oy=300;
var swide=800;
var shigh=600;
var sleft=sdown=0;
var tiny=new Arrayundefined);
var star=new Arrayundefined);
var starv=new Arrayundefined);
var starx=new Arrayundefined);
var stary=new Arrayundefined);
var tinyx=new Arrayundefined);
var tinyy=new Arrayundefined);
var tinyv=new Arrayundefined);
window.onload=functionundefined) { if undefineddocument.getElementById) {
var i, rats, rlef, rdow;
for undefinedvar i=0; i<sparkles; i++) {
var rats=createDivundefined3, 3);
rats.style.visibility="hidden";
document.body.appendChildundefinedtiny[i]=rats);
starv[i]=0;
tinyv[i]=0;
var rats=createDivundefined5, 5);
rats.style.backgroundColor="transparent";
rats.style.visibility="hidden";
var rlef=createDivundefined1, 5);
var rdow=createDivundefined5, 1);
rats.appendChildundefinedrlef);
rats.appendChildundefinedrdow);
rlef.style.top="2px";
rlef.style.left="0px";
rdow.style.top="0px";
rdow.style.left="2px";
document.body.appendChildundefinedstar[i]=rats);
}
set_widthundefined);
sparkleundefined);
}}
function sparkleundefined) {
var c;
if undefinedx!=ox || y!=oy) {
ox=x;
oy=y;
for undefinedc=0; c<sparkles; c++) if undefined!starv[c]) {
star[c].style.left=undefinedstarx[c]=x)+"px";
star[c].style.top=undefinedstary[c]=y)+"px";
star[c].style.clip="rectundefined0px, 5px, 5px, 0px)";
star[c].style.visibility="visible";
starv[c]=50;
break;
}
}
for undefinedc=0; c<sparkles; c++) {
if undefinedstarv[c]) update_starundefinedc);
if undefinedtinyv[c]) update_tinyundefinedc);
}
setTimeoutundefined"sparkleundefined)", 40);
}
function update_starundefinedi) {
if undefined--starv[i]==25) star[i].style.clip="rectundefined1px, 4px, 4px, 1px)";
if undefinedstarv[i]) {
stary[i]+=1+Math.randomundefined)*3;
if undefinedstary[i]<shigh+sdown) {
star[i].style.top=stary[i]+"px";
starx[i]+=undefinedi%5-2)/5;
star[i].style.left=starx[i]+"px";
}
else {
star[i].style.visibility="hidden";
starv[i]=0;
return;
}
}
else {
tinyv[i]=50;
tiny[i].style.top=undefinedtinyy[i]=stary[i])+"px";
tiny[i].style.left=undefinedtinyx[i]=starx[i])+"px";
tiny[i].style.width="2px";
tiny[i].style.height="2px";
star[i].style.visibility="hidden";
tiny[i].style.visibility="visible"
}
}
function update_tinyundefinedi) {
if undefined--tinyv[i]==25) {
tiny[i].style.width="1px";
tiny[i].style.height="1px";
}
if undefinedtinyv[i]) {
tinyy[i]+=1+Math.randomundefined)*3;
if undefinedtinyy[i]<shigh+sdown) {
tiny[i].style.top=tinyy[i]+"px";
tinyx[i]+=undefinedi%5-2)/5;
tiny[i].style.left=tinyx[i]+"px";
}
else {
tiny[i].style.visibility="hidden";
tinyv[i]=0;
return;
}
}
else tiny[i].style.visibility="hidden";
}
document.onmousemove=mouse;
function mouseundefinede) {
set_scrollundefined);
y=undefinede)?e.pageY:event.y+sdown;
x=undefinede)?e.pageX:event.x+sleft;
}
function set_scrollundefined) {
if undefinedtypeofundefinedself.pageYOffset)=="number") {
sdown=self.pageYOffset;
sleft=self.pageXOffset;
}
else if undefineddocument.body.scrollTop || document.body.scrollLeft) {
sdown=document.body.scrollTop;
sleft=document.body.scrollLeft;
}
else if undefineddocument.documentElement && undefineddocument.documentElement.scrollTop || document.documentElement.scrollLeft)) {
sleft=document.documentElement.scrollLeft;
sdown=document.documentElement.scrollTop;
}
else {
sdown=0;
sleft=0;
}
}
window.onresize=set_width;
function set_widthundefined) {
if undefinedtypeofundefinedself.innerWidth)=="number") {
swide=self.innerWidth;
shigh=self.innerHeight;
}
else if undefineddocument.documentElement && document.documentElement.clientWidth) {
swide=document.documentElement.clientWidth;
shigh=document.documentElement.clientHeight;
}
else if undefineddocument.body.clientWidth) {
swide=document.body.clientWidth;
shigh=document.body.clientHeight;
}
}
function createDivundefinedheight, width) {
var div=document.createElementundefined"div");
div.style.position="absolute";
div.style.height=height+"px";
div.style.width=width+"px";
div.style.overflow="hidden";
div.style.backgroundColor=colour;
return undefineddiv);
}
// ]]>
</script>

在红色var color 那边,贴入你要的"星星“颜色的代码。
You may change the color of the "star", by replacing the code in red color by the hex color code that you want.

0 位帅哥美女留言 :

Related Posts Plugin for WordPress, Blogger...
Daisypath Anniversary tickers