DW里面html鼠标点击特效,【好好学习】-DW-鼠标点击 爆米花特效 代码

这篇博客介绍了如何在Dreamweaver(DW)中实现一个HTML鼠标点击后的爆米花特效。通过添加和执行JavaScript代码,当鼠标按下时,会触发一系列火花动画效果,这些效果会从点击位置飞出并消失,为网页增添动态交互体验。
摘要由CSDN通过智能技术生成

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

脚本说明:

第一步:把如下代码加入

区域中

var ver   = navigator.appVersion;

var dom   = document.getElementById ? 1 : 0;

var ie5   = (ver.indexOf("MSIE 5") > -1 && dom) ? 1 : 0;

var n   = (document.layers);

var ie = (document.all);

var sparksAflyin = 0;

var totalSparks = 0;

var sparksOn = 1;

function initMouseEvents() {

document.onmousedown = mouseDown;

if (n) document.captureEvents(Event.MOUSEDOWN | Event.MOUSEMOVE);

}

function mouseDown(e) {

if (sparksOn) {

var mousex = (n) ? e.pageX : event.x+document.body.scrollLeft;

var mousey = (n) ? e.pageY : event.y+document.body.scrollTop;

if (!sparksAflyin) {

for (var k = 0; k <= 9; k++)

eval('SHOW("sDiv'+k+'")');

sparksAflyin = 1;

totalSparks = 0;

for(i = 0;i <= 9; i++)

eval('moveTo('+i+',0,'+mousex+','+mousey+')');

}

}

}

function moveTo(i,j, mousex, mousey){

if (j < eval('anim_'+i+'_x.length') ){

var tempx = eval('anim_'+i+'_x[j]+mousex');

var tempy = eval('anim_'+i+'_y[j]+mousey');

if (ie) {

if(tempy+30 > (document.body.offsetHeight+document.body.scrollTop))

tempy = document.body.offsetHeight+document.body.scrollTop-30;

if(tempx+30 > (document.body.offsetWidth+document.body.scrollLeft))

tempx = document.body.offsetWidth+document.body.scrollLeft-30;

eval('document.all.sDiv'+i+'.style.left = tempx;');

eval('document.all.sDiv'+i+'.style.top   = tempy;');

}

if (n) {

eval('document.layers.sDiv'+i+'.left = tempx;');

eval('document.layers.sDiv'+i+'.top   = tempy;');

}

j++;

//   timeout: 50 = fireworks speed, larger number = slower speed

setTimeout("moveTo("+i+","+j+","+mousex+","+mousey+")",50)

}

else {

eval('HIDE("sDiv'+i+'")');

totalSparks++;

}

if (totalSparks == 10) {

sparksAflyin = 0;

totalSparks   = 0;

}

}

function SHOW(divName){

if (document.all)

eval('document.all.'+divName+'.style.visibility = "visible";');

else if (document.layers)

eval('document.layers["'+divName+'"].visibility = "visible";');

}

function HIDE(divName){

if (document.all)

eval('document.all.'+divName+'.style.visibility = "hidden";');

else if (document.layers)

eval('document.layers["'+divName+'"].visibility = "hide";');

}

anim_0_x=new Array(20,20,10,0,0,0,0,0,0,0,0,0);

anim_0_y=new Array(-20,-40,-60,-80,-60,-40,-20,0,20,40,60,80);

anim_1_x=new Array(20,20,17,36,60,78,90,92,93,98,108,120,133,152,181);

anim_1_y=new Array(-20,-20,-33,-38,-38,-27,-2,25,51,84,113,141,162,212,253);

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值