Discuz!官方免费开源建站系统

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索

[分享] 要完成此效果需要两个步骤

[复制链接]
SSAY 发表于 2007-11-11 10:33:34 | 显示全部楼层 |阅读模式
第一步:把如下代码加入到<head>区域中

<STYLE>DIV {
POSITION: absolute
}
DIV.clButton {
HEIGHT: 20px; TOP: -200px; WIDTH: 20px
}
#divStat {
HEIGHT: 20px; LEFT: 8px; TOP: 12px; WIDTH: 130px
}
#divStatCont {
HEIGHT: 45px; TOP: -200px; WIDTH: 125px
}
SPAN.clStat {
COLOR: #606fa2; FONT-FAMILY: arial,helvetica; FONT-SIZE: 10px
}
#divDHTML {
TOP: 20px; WIDTH: 100px
}
DIV.clLink {
FONT-FAMILY: arial,helvetica; FONT-SIZE: 12px; FONT-WEIGHT: bold; VISIBILITY: hidden
}
#divExplain {
FONT-FAMILY: arial,helvetica; FONT-SIZE: 12px
}
</STYLE>


第二步:把如下代码加入到<body>区域中

<script>
function checkBrowser(){
this.ver=navigator.appVersion
this.dom=document.getElementById?1:0
this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0;
this.ie4=(document.all && !this.dom)?1:0;
this.ns5=(this.dom && parseInt(this.ver) >= 5) ?1:0;
this.ns4=(document.layers && !this.dom)?1:0;
this.ie=this.ie4||this.ie5
this.bw=(this.ie5 || this.ie4 || this.ns4 || this.ns5)
return this
}
bw=new checkBrowser()

//Preload
function preLoad(){
for(i=0;i<arguments.length;i++){
this=new Image()
this.src=arguments
}
return this
}

//Place your images in here
imgButLetter=new preLoad("http://ww.jojoo.net/include/1.jpg","http://www.jojoo.net/include/2.jpg","http://www.jojoo.net/include/4.jpg","http://www.jojoo.net/include/2.jpg","http://www.jojoo.net/include/3.jpg")
imgButCircle=new preLoad("http://www.jojoo.net/include/5.jpg","http://www.jojoo.net/include/2.jpg","http://www.jojoo.net/include/6.jpg","http://www.jojoo.net/include/2.jpg","http://www.jojoo.net/include/2.jpg")

//How many "balls" do you have
numBalls=5

function makePageCoords(){
this.x=0;this.x2=(bw.ns4 || bw.ns5)?innerWidth:document.body.offsetWidth-20;
this.y=0;this.y2=(bw.ns4 || bw.ns5)?innerHeight:document.body.offsetHeight-5;
this.x50=this.x2/2; this.y50=this.y2/2;
return this;
}
function makeObj(obj,nest){
nest=(!nest) ? '':'document.'+nest+'.'
this.el=bw.dom?document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?eval(nest+'document.'+obj):0;
this.css=bw.dom?document.getElementById(obj).style:bw.ie4?document.all[obj].style:bw.ns4?eval(nest+'document.'+obj):0;
this.ref=bw.ns4?this.css.document:document;
this.width=bw.ns4?this.css.document.width:this.el.offsetWidth
this.moveBy=b_moveBy; this.moveIt=b_moveIt; this.writeIt=b_writeIt;
this.slide=b_slide; this.slideIt=b_slideIt;
this.showIt=b_showIt; this.hideIt=b_hideIt;
this.obj = obj + "Object"; eval(this.obj + "=this")
}
function b_moveIt(x,y){this.x=x; this.y=y; this.css.left=this.x; this.css.top=this.y}
function b_moveBy(x,y){this.x+=x; this.y+=y; this.css.left=this.x; this.css.top=this.y}
function b_showIt(){this.css.visibility="visible"}
function b_hideIt(){this.css.visibility="hidden"}
function b_writeIt(text){
if(bw.ns4){this.ref.write(text);this.ref.close()}
else this.el.innerHTML=text
}
function s_writeIt(text){
text='<span class="clStat">'+text+'</span>'
this.write(text)
}
function b_slideIt(endx,endy,inc,speed,fn,wh) {
if (!this.slideactive) {var distx = endx - this.x;var disty = endy - this.y
var num = Math.sqrt(Math.pow(distx,2) + Math.pow(disty,2))/inc
var dx = distx/num;var dy = disty/num
this.slideactive = 1; this.slide(dx,dy,endx,endy,speed,fn,wh)}}
function b_slide(dx,dy,endx,endy,speed,fn,wh) {
if (!fn) fn = null; if(!wh) wh=null
if (this.slideactive && (Math.floor(Math.abs(dx))<Math.floor(Math.abs(endx-this.x)) || Math.floor(Math.abs(dy))<Math.floor(Math.abs(endy-this.y)))) {
this.moveIt(this.x+dx,this.y+dy); eval(wh)
slidTim=setTimeout(this.obj+".slide("+dx+","+dy+","+endx+","+endy+","+speed+",'"+fn+"','"+wh+"')",speed)
}else{this.slideactive = 0;this.moveIt(endx,endy);eval(fn)}}
/************************************************************************************************
Initiating page. Setting variables. Making objects. Starting animation
***********************************************************************************************/
function ballInit(){
page=new makePageCoords()
//Set the stop placements of each ball:
ballXstop=new Array(page.x50-70,page.x50-40,page.x50-10,page.x50+20,page.x50+50)
ballYstop=new Array(page.y50-12,page.y50-12,page.y50-12,page.y50-12,page.y50-12)
//Set the angles of each ball
angles=new Array(-180,-90,0,90,180)

oBut=new Array()
for(i=0;i<numBalls;i++){
oBut=new makeObj('divBut'+i)
oBut.text=new makeObj('divLink'+i)
oBut.moveIt(i*100,-50)
}
oStat=new makeObj('divStat','divStatCont')
oStat.write=b_writeIt;
oStat.writeIt=s_writeIt;
oStatCont=new makeObj('divStatCont')
oStatCont.moveIt(page.x2-135,page.y2-50)
oDHTML=new makeObj('divDHTML')
oDHTML.moveIt(page.x50-72,page.y50-13)
doBall()
}
/************************************************************************************************
Ballpart start
***********************************************************************************************/
var ballBottom
var ballTop=0
var ballSpeed=25
var ballRight
var ballLeft=0
var xsling=60
var ysling=20
var got=0
ballGoing=true;

function fall(count){
var fover=false
for(var i=0;i<oBut.length;i++){
if(oBut.ball.ready){
num=Math.round(Math.random()*4)
oBut.ref["imgBut"+i].src=imgButLetter[num].src
if(count==400 || count==550 || count==700){
oBut.ball.moveXpx-=2
oBut.ball.moveYpx+=2
}
fover=true
if(oBut.y<ballBottom && !oBut.ball.way){
if(oBut.x>ballRight-16 && oBut.x<ballRight) oBut.ball.xmove=-oBut.ball.moveXpx
else if(oBut.x>ballLeft-8 && oBut.x<ballLeft+8) oBut.ball.xmove=oBut.ball.moveXpx
oBut.moveBy(oBut.ball.xmove,oBut.ball.moveYpx)
oBut.ball.way=0
}else{
oBut.ball.way=1
}
if(oBut.y>ballTop && oBut.ball.way){
if(oBut.x>ballRight-16 && oBut.x<ballRight) oBut.ball.xmove=-oBut.ball.moveXpx
else if(oBut.x>ballLeft-8 && oBut.x<ballLeft+8) oBut.ball.xmove=oBut.ball.moveXpx
oBut.moveBy(oBut.ball.xmove,-oBut.ball.moveYpx)
oBut.ball.way=1
}else{
oBut.ball.way=0
}
if((oBut.x>oBut.ball.xpos-xsling && oBut.x<oBut.ball.xpos+xsling) && (oBut.y>oBut.ball.ypos-ysling && oBut.y<oBut.ball.ypos+ysling)){
oBut.ball.ready=false
oBut.ref["imgBut"+i].src=imgButLetter.src
oBut.slideIt(oBut.ball.xpos,oBut.ball.ypos,3,10)
got++
if(got!=oBut.length) oStat.writeIt('看到效果了没...<br>'+got +' placed, '+ (oBut.length-got) +' to go')
else{
afterBall()
}
}
}
}
count++
if(fover)setTimeout("fall("+count+")",ballSpeed)
}
function makeBall(xspeed,yspeed,xpos,ypos){
this.xpos=xpos
this.ypos=ypos
this.way=0
this.ready=true
this.moveXpx=xspeed
this.moveYpx=yspeed
num=Math.round(Math.random())
if(num) this.xmove=4
else this.xmove=-4
return this
}
function doBall(){
oStat.writeIt('JavaScript Fairyland')
ballBottom=(bw.ie)?page.y2-27:page.y2-10;
ballRight=(bw.ie)?page.x2-27:page.x2-5;
for(i=0;i<oBut.length;i++){
num=Math.round(Math.random()*3)
oBut.ball=new makeBall(16-num-1,16-num,ballXstop,ballYstop)
}
fall(0)
}
/************************************************************************************************
Ball part end
***********************************************************************************************/

/************************************************************************************************
After ball part
***********************************************************************************************/
function afterBall(){
oStat.writeIt('JavaScript Fairyland')
ballGoing=false
setTimeout("oDHTML.hideIt(); oStat.writeIt('Making circles'); stopLetter("+oBut.length+")",300)
}
function stopLetter(num){
if(num>0){
num--
oBut[num].ref["imgBut"+num].src=imgButCircle[num].src
setTimeout("stopLetter("+num+")",100)
}else{
oStat.writeIt('JavaScript Fairyland')
slideCircles(0)
}
}
function slideCircles(num){
if(num<30){
for(i=0;i<oBut.length;i++){oBut.moveBy(-4+(i*2),0)}
num++; setTimeout("slideCircles("+num+")",40)
}else{
oStat.writeIt('JavaScript Fairyland')
c_left=oBut[2].x; c_top=oBut[2].y; circleCircles(0,0)
}
}
var c_left,c_top; var angle=0;
function circleCircles(num,speed){
if(num<361){
for(i=0;i<oBut.length;i++){oBut.moveIt(Math.round(c_left + angles*Math.cos(angle*Math.PI/180)),Math.round(c_top + angles*Math.sin(angle*Math.PI/180)))}
angle+=speed;
if(num<180) speed=speed+0.2; else speed=speed-0.2
num++;setTimeout("circleCircles("+num+","+speed+")",15)
}else{
end(0)
}
}
function end(num){
if(num<oBut.length){
oBut[num].text.moveIt((oBut[num].x+17)-(oBut[num].text.width/2),oBut[num].y+30)
oBut[num].text.showIt()
num++
setTimeout("end("+num+")",100)
}else{
oStat.writeIt('JavaScript Fairyland')
}
}
/************************************************************************************************
After ball part end
***********************************************************************************************/





//Starting animation of page load.
onload=ballInit;
</script>
<DIV id=divExplain></DIV><!-- Stat part -->
<DIV id=divStatCont><IMG alt="" border=0 height=43
src="../wydh/images/98/status.gif" width=125>
<DIV id=divStat></DIV></DIV><!-- Menu -->
<DIV id=divDHTML><IMG alt="" border=0 height=32
src="../wydh/images/98/dhtml.gif" width=144> </DIV><!-- Place your links in the hrefs below -->
<DIV class=clButton id=divBut0><A
href="link.htm"><IMG alt=""
border=0 height=25 name=imgBut0 src="../wydh/images/98/letter_1.gif"
width=25></A> </DIV>
<DIV class=clButton id=divBut1><A
href="link.htm"><IMG alt=""
border=0 height=25 name=imgBut1 src="../wydh/images/98/letter_2.gif"
width=25></A> </DIV>
<DIV class=clButton id=divBut2><A
href="link.htm"><IMG alt=""
border=0 height=25 name=imgBut2 src="../wydh/images/98/letter_3.gif"
width=25></A> </DIV>
<DIV class=clButton id=divBut3><A
href="link.htm"><IMG alt=""
border=0 height=25 name=imgBut3 src="../wydh/images/98/letter_4.gif"
width=25></A> </DIV>
<DIV class=clButton id=divBut4><A
href="link.htm"><IMG alt=""
border=0 height=25 name=imgBut4 src="../wydh/images/98/letter_5.gif"
width=25></A> </DIV>
<DIV class=clLink id=divLink0>Link 1 </DIV>
<DIV class=clLink id=divLink1>Link 2 </DIV>
<DIV class=clLink id=divLink2>Link 3 </DIV>
<DIV class=clLink id=divLink3>Link 4 </DIV>
<DIV class=clLink id=divLink4>Link 5 </DIV>
9so 发表于 2007-11-11 10:47:51 | 显示全部楼层
回复

使用道具 举报

翅膀。 发表于 2007-11-11 11:10:14 | 显示全部楼层
这是什么啊。。。。。。。。
回复

使用道具 举报

茄子 发表于 2007-11-12 10:03:38 | 显示全部楼层
请说明什么东东!
谢谢配合~
回复

使用道具 举报

紫琼 发表于 2007-11-12 10:09:28 | 显示全部楼层
完成啥效果啊
回复

使用道具 举报

cn256 发表于 2007-11-12 10:45:08 | 显示全部楼层
完成什么效果呢?
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|Discuz! 官方站 ( 皖ICP备16010102号 )star

GMT+8, 2025-2-26 22:53 , Processed in 0.021823 second(s), 3 queries , Gzip On, Redis On.

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表