大家都喜欢在自己的博客上做上一些漂亮的特效,能在自己的网页上适当做一些特别的效果确实会赏心悦目,在这里告诉大家一些简单漂亮的特效,只要把下面的代码加入在模板的Body,就会有一串跳动的心跟着鼠标移动了,如果大家想看效果可以去 http://rain.tyblog.com (现在只要打开本篇文章就能看到这种效果了) 当然如果你喜欢还可以在鼠标后面跟着一段文字,或者一圈旋转的个人信息等等。
如遇到有关电子电脑的问题,欢迎在留言栏留下你的困惑,在本人有时间的前提下愿意为你解决。
<script src="blog URL"></script>
<DIV id=dot0 style="VISIBILITY: hidden; WIDTH: 14px; POSITION: absolute; HEIGHT: 14px"><IMG height=14 src="picture1" width=14></DIV>
<DIV id=dot1 style="WIDTH: 14px; POSITION: absolute; HEIGHT: 14px"><IMG height=14 src="picture1" width=14></DIV>
<DIV id=dot2 style="WIDTH: 14px; POSITION: absolute; HEIGHT: 14px"><IMG height=14 src="picture1" width=14></DIV>
<DIV id=dot3 style="WIDTH: 14px; POSITION: absolute; HEIGHT: 14px"><IMG height=14 src="picture2" width=14></DIV>
<DIV id=dot4 style="WIDTH: 14px; POSITION: absolute; HEIGHT: 14px"><IMG height=14 src="picture2if" width=14></DIV>
<DIV id=dot5 style="WIDTH: 14px; POSITION: absolute; HEIGHT: 14px"><IMG height=14 src="picturte3" width=14></DIV>
<DIV id=dot6 style="LEFT: 0px; WIDTH: 1px; POSITION: absolute; TOP: 595px; HEIGHT: 14px"><IMG height=14 src="picture3" width=14></DIV>
<SCRIPT language=JavaScript>
<!-- hide code
/*
鼠标下的弹性链条
*/
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) {
}
// set their positions
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;
}
// bounce of 3 walls (leave ceiling open)
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>