| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 719 人关注过本帖
标题:[分享]网页的一些效果——源码
只看楼主 加入收藏
oヤ偽妳變壞
Rank: 2
等 级:新手上路
威 望:4
帖 子:2251
专家分:0
注 册:2006-3-19
收藏
 问题点数:0 回复次数:7 
[分享]网页的一些效果——源码

1.跟随鼠标的光环:
<!--将以下代码加入HTML的<Body></Body>之间-->
<LAYER NAME="a0" LEFT="10" TOP="10" VISIBILITY="SHOW" BGCOLOR="#ffffff" CLIP="0,0,1,1">
</LAYER>
<LAYER NAME="a1" LEFT="10" TOP="10" VISIBILITY="SHOW" BGCOLOR="#fff000" CLIP="0,0,1,1">
</LAYER>
<LAYER NAME="a2" LEFT="10" TOP="10" VISIBILITY="SHOW" BGCOLOR="#ffa000" CLIP="0,0,1,1">
</LAYER>
<LAYER NAME="a3" LEFT="10" TOP="10" VISIBILITY="SHOW" BGCOLOR="#ff00ff" CLIP="0,0,1,1">
</LAYER>
<LAYER NAME="a4" LEFT="10" TOP="10" VISIBILITY="SHOW" BGCOLOR="#00ff00" CLIP="0,0,1,1">
</LAYER>
<LAYER NAME="a5" LEFT="10" TOP="10" VISIBILITY="SHOW" BGCOLOR="#FF00FF" CLIP="0,0,1,1">
</LAYER>
<LAYER NAME="a6" LEFT="10" TOP="10" VISIBILITY="SHOW" BGCOLOR="#FF0000" CLIP="0,0,1,1">
</LAYER>
<LAYER NAME="a7" LEFT="10" TOP="10" VISIBILITY="SHOW" BGCOLOR="#ffffff" CLIP="0,0,2,2">
</LAYER>
<LAYER NAME="a8" LEFT="10" TOP="10" VISIBILITY="SHOW" BGCOLOR="#fff000" CLIP="0,0,2,2">
</LAYER>
<LAYER NAME="a9" LEFT="10" TOP="10" VISIBILITY="SHOW" BGCOLOR="#ffa000" CLIP="0,0,2,2">
</LAYER>
<LAYER NAME="a10" LEFT="10" TOP="10" VISIBILITY="SHOW" BGCOLOR="#ff00ff" CLIP="0,0,2,2">
</LAYER>
<LAYER NAME="a11" LEFT="10" TOP="10" VISIBILITY="SHOW" BGCOLOR="#00ff00" CLIP="0,0,2,2">
</LAYER>
<LAYER NAME="a12" LEFT="10" TOP="10" VISIBILITY="SHOW" BGCOLOR="#0000ff" CLIP="0,0,2,2">
</LAYER>
<LAYER NAME="a13" LEFT="10" TOP="10" VISIBILITY="SHOW" BGCOLOR="#FF0000" CLIP="0,0,2,2">
</LAYER>
<script language="JavaScript">

if (document.all){
with (document){
write('<div id="starsDiv" style="position:absolute;top:0px;left:0px">')
write('<div style="position:relative;width:1px;height:1px;background:#ffffff;font-size:1px;visibility:visible"></div>')
write('<div style="position:relative;width:1px;height:1px;background:#fff000;font-size:1px;visibility:visible"></div>')
write('<div style="position:relative;width:1px;height:1px;background:#ffa000;font-size:1px;visibility:visible"></div>')
write('<div style="position:relative;width:1px;height:1px;background:#ff00ff;font-size:1px;visibility:visible"></div>')
write('<div style="position:relative;width:1px;height:1px;background:#00ff00;font-size:1px;visibility:visible"></div>')
write('<div style="position:relative;width:1px;height:1px;background:#0000ff;font-size:1px;visibility:visible"></div>')
write('<div style="position:relative;width:1px;height:1px;background:#FF0000;font-size:1px;visibility:visible"></div>')
write('<div style="position:relative;width:2px;height:2px;background:#ffffff;font-size:2px;visibility:visible"></div>')
write('<div style="position:relative;width:2px;height:2px;background:#fff000;font-size:2px;visibility:visible"></div>')
write('<div style="position:relative;width:2px;height:2px;background:#ffa000;font-size:2px;visibility:visible"></div>')
write('<div style="position:relative;width:2px;height:2px;background:#ff00ff;font-size:2px;visibility:visible"></div>')
write('<div style="position:relative;width:2px;height:2px;background:#00ff00;font-size:2px;visibility:visible"></div>')
write('<div style="position:relative;width:2px;height:2px;background:#0000ff;font-size:2px;visibility:visible"></div>')
write('<div style="position:relative;width:3px;height:3px;background:#FF0000;font-size:3px;visibility:visible"></div>')
write('</div>')
}
}

if (document.layers)
{window.captureEvents(Event.MOUSEMOVE);}
var yBase = 200;
var xBase = 200;
var step = 1;
var currStep = 0;
var Xpos = 1;
var Ypos = 1;
if (document.all)
{
function MoveHandler(){
Xpos = document.body.scrollLeft+event.x;
Ypos = document.body.scrollTop+event.y;
}
document.onmousemove = MoveHandler;
}

else if (document.layers)
{
function xMoveHandler(evnt){
Xpos = evnt.pageX;
Ypos = evnt.pageY;
}
window.onMouseMove = xMoveHandler;
}

function animateLogo() {
if (document.all)
{
yBase = window.document.body.offsetHeight/6;
xBase = window.document.body.offsetWidth/6;
}
else if (document.layers)
{
yBase = window.innerHeight/8;
xBase = window.innerWidth/8;
}

if (document.all)
{
for ( i = 0 ; i < starsDiv.all.length ; i++ )
{
starsDiv.all.style.top = Ypos + yBase*Math.sin((currStep + i*4)/12)*Math.cos(400+currStep/200);
starsDiv.all.style.left = Xpos + xBase*Math.sin((currStep + i*3)/10)*Math.sin(currStep/200);
}
}

else if (document.layers)
{
for ( j = 0 ; j < 14 ; j++ ) //number of NS layers!
{
var templayer="a"+j
document.layers[templayer].top = Ypos + yBase*Math.sin((currStep + j*4)/12)*Math.cos(400+currStep/200);
document.layers[templayer].left = Xpos + xBase*Math.sin((currStep + j*3)/10)*Math.sin(currStep/200);
}
}
currStep+= step;
setTimeout("animateLogo()", 10);
}
animateLogo();
</script>

[此贴子已经被作者于2006-9-27 20:31:57编辑过]

搜索更多相关主题的帖子: 网页 源码 效果 分享 
2006-09-27 20:30
oヤ偽妳變壞
Rank: 2
等 级:新手上路
威 望:4
帖 子:2251
专家分:0
注 册:2006-3-19
收藏
得分:0 

2.闪电效果的背景:
<!--将以下代码加入HTML的<Body></Body>之间-->
<script LANGUAGE="JavaScript">
function blinkOn(){
theWin.document.bgColor = "000000"
nTimes++
JSCTimeOutID = window.setTimeout("blinkOff()",50);
}
function blinkOff(){
theWin.document.bgColor = "FFFFFF"
if (nTimes < 3)
JSCTimeOutID = window.setTimeout("blinkOn()",50);
else theWin.history.go(0)
}
function blinkit(aWin)
{
nTimes = 0
theWin = aWin
JSCTimeOutID = window.setTimeout("blinkOn()",50);
}
</script>

<form>
<div align="center"><center><p><input TYPE="BUTTON" VALUE="让暴风雨来的更猛烈些吧!" onClick="blinkit(self)">
</p>
</center></div>
</form>

2006-09-27 20:32
oヤ偽妳變壞
Rank: 2
等 级:新手上路
威 望:4
帖 子:2251
专家分:0
注 册:2006-3-19
收藏
得分:0 

3.黑客帝国的背景效果:
<!--将以下代码加入HTML的<Body></Body>之间-->
<script language="JavaScript">
<!--
if (document.all){
Cols=6;
Cl=24;//Space's are included so real length is 48!
Cs=10;
Ts=10;
Tc='#008800';
Tc1='#00ff00';
MnS=20;
MxS=30;
I=Cs;
Sp=new Array();S=new Array();Y=new Array();
C=new Array();M=new Array();B=new Array();
RC=new Array();E=new Array();Tcc=new Array(0,1);
document.write("<div id='Container' style='position:absolute;top:0;left:-"+Cs+"'>");
document.write("<div style='position:relative'>");
for(i=0; i < Cols; i++){
S=I+=Cs;
document.write("<div id='A' style='position:absolute;top:0;font-family:Arial;font-size:"
+Ts+"px;left:"+S+";width:"+Ts+"px;height:0px;color:"+Tc+";visibility:hidden'></div>");
}
document.write("</div></div>");

for(j=0; j < Cols; j++){
RC[j]=1+Math.round(Math.random()*Cl);
Y[j]=0;
Sp[j]=Math.round(MnS+Math.random()*MxS);
for(i=0; i < RC[j]; i++){
B='';
C=Math.round(Math.random()*1)+' ';
M[j]=B[0]+=C;
}
}
function Cycle(){
Container.style.top=window.document.body.scrollTop;
for (i=0; i < Cols; i++){
var r = Math.floor(Math.random()*Tcc.length);
E = '<font color='+Tc1+'>'+Tcc[r]+'</font>';
Y+=Sp;

if (Y > window.document.body.clientHeight){
for(i2=0; i2 < Cols; i2++){
RC[i2]=1+Math.round(Math.random()*Cl);
for(i3=0; i3 < RC[i2]; i3++){
B[i3]='';
C[i3]=Math.round(Math.random()*1)+' ';
C[Math.floor(Math.random()*i2)]=' '+' ';
M=B[0]+=C[i3];
Y=-Ts*M.length/1.5;
A.style.visibility='visible';
}
Sp=Math.round(MnS+Math.random()*MxS);
}
}
A.style.top=Y;
A.innerHTML=M+' '+E+' ';
}
setTimeout('Cycle()',20)
}
Cycle();
}
// -->
</script>

2006-09-27 20:32
oヤ偽妳變壞
Rank: 2
等 级:新手上路
威 望:4
帖 子:2251
专家分:0
注 册:2006-3-19
收藏
得分:0 

4.璀璨的页面效果:
<!--将以下代码加入HTML的<Body></Body>之间-->
<script language="JavaScript">
<!-- Space Variation by kurt.jojoo@jojoo.net
if (document.all){
xL=5;
xH=0;
xW=0;
xR=0;
xE=0;
xMY=0;
xMX=0;
xWd=0;
xHd=0;
xF=new Array();
xY=new Array();
xX=new Array();
xS=new Array();
xA=new Array();
xB=new Array();
ini=new Array();
cl=new Array('#fff000','#0000FF','#ff0000','#00ff00','#ff00ff','#ffa500')
document.write('<div id="xouter" style="position:absolute;top:0px;left:0px"><div style="position:relative">');
for (i=0; i < xL; i++){
document.write('<div id="xie" style="position:absolute;top:0;left:0;width:10px;height:10px;'
+'font-family:Courier New;font-size:50px;color:#ffffff">.</div>');
}
document.write('</div></div>');
//Initial Placement!
function Set(){
for (i=0; i < xL; i++){
xH=window.document.body.offsetHeight;
xW=window.document.body.offsetWidth;
xA=Math.round(Math.random()*xH);
xB=Math.round(Math.random()*xW);
xS=Math.random()*0.07+0.05;
xR=Math.round(Math.random()*3);
xE=Math.round(Math.random()*2500+50)
if (xR == 3) xB=-xE;
if (xR == 2) xB=xW+xE;
if (xR == 1) xA=-xE;
if (xR == 0) xA=xH;
xF=xW/14;
}
}
Set();
function Assign(){
xouter.style.top=document.body.scrollTop;
for (i=0; i < xL; i++){
xF-=xS*25;
if (xF < 4) xF=3;
xie.style.top =xY;
xie.style.left=xX;
xie.style.fontSize=xF;
xie.style.filter='glow(color='+ini+', strength='+xF/3+')';
}
}
function fly(){
var N=Math.floor(Math.random()*cl.length)
xMY=window.document.body.clientHeight/2;
xMX=window.document.body.clientWidth/2;
xWd=Math.round(Math.random()*40+5);
xHd=Math.round(Math.random()*30+5);
for (i=0; i < xL; i++)
{
xY=xA+=(xMY-xA)*(xS);
xX=xB+=(xMX-xB)*(xS);
if ((xX > xMX-xWd) && (xX < xMX+xWd) && (xY > xMY-xHd) && (xY < xMY+xHd)){

xH=window.document.body.offsetHeight;
xW=window.document.body.offsetWidth;
xA=Math.round(Math.random()*xH);
xB=Math.round(Math.random()*xW);
xS=Math.random()*0.05+0.05;
xR=Math.round(Math.random()*3);
xE=Math.round(Math.random()*50+50)
if (xR == 3) xB=-xE;
if (xR == 2) xB=xW+xE;
if (xR == 1) xA=-xE;
if (xR == 0) xA=xH+xE;
}
if ((xX < 0) || (xX > xW) || (xY < 0) || (xY > xH))
{
xF=xW/14;
ini=cl[N];
}
}
Assign();
setTimeout('fly()',10);
}
fly();
}
// -->
</script>

[此贴子已经被作者于2006-9-27 20:36:40编辑过]

2006-09-27 20:33
oヤ偽妳變壞
Rank: 2
等 级:新手上路
威 望:4
帖 子:2251
专家分:0
注 册:2006-3-19
收藏
得分:0 

5.纪念日倒计时:
<!--将以下代码加入HTML的<Body></Body>之间-->
<SCRIPT language=JavaScript1.2>
function setcountdown(theyear,themonth,theday){
yr=theyear;mo=themonth;da=theday
}
setcountdown(2008,7,12)
var occasion="2008北京奥运会"
var message_on_occasion="盼望已久的时刻终于来到了!"
var countdownwidth='480px'
var countdownheight='20px'
var countdownbgcolor='tan'
var opentags='<font face="宋体"><small>'
var closetags='</small></font>'
var montharray=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")
var crosscount=''
function start_countdown(){
if (document.layers)
document.countdownnsmain.visibility="show"
else if (document.all||document.getElementById)
crosscount=document.getElementById&&!document.all?document.getElementById("countdownie") : countdownie
countdown()
}

if (document.all||document.getElementById)
document.write('<span id="countdownie" style="width:'+countdownwidth+'; background-color:'+countdownbgcolor+'"></span>')

window.onload=start_countdown


function countdown(){
var today=new Date()
var todayy=today.getYear()
if (todayy < 1000)
todayy+=1900
var todaym=today.getMonth()
var todayd=today.getDate()
var todayh=today.getHours()
var todaymin=today.getMinutes()
var todaysec=today.getSeconds()
var todaystring=montharray[todaym]+" "+todayd+", "+todayy+" "+todayh+":"+todaymin+":"+todaysec
futurestring=montharray[mo-1]+" "+da+", "+yr
dd=Date.parse(futurestring)-Date.parse(todaystring)
dday=Math.floor(dd/(60*60*1000*24)*1)
dhour=Math.floor((dd%(60*60*1000*24))/(60*60*1000)*1)
dmin=Math.floor(((dd%(60*60*1000*24))%(60*60*1000))/(60*1000)*1)
dsec=Math.floor((((dd%(60*60*1000*24))%(60*60*1000))%(60*1000))/1000*1)
if(dday<=0&&dhour<=0&&dmin<=0&&dsec<=1&&todayd==da){
if (document.layers){
document.countdownnsmain.document.countdownnssub.document.write(opentags+message_on_occasion+closetags)
document.countdownnsmain.document.countdownnssub.document.close()
}
else if (document.all||document.getElementById)
crosscount.innerHTML=opentags+message_on_occasion+closetags
return
}
else if (dday<=-1){
if (document.layers){
document.countdownnsmain.document.countdownnssub.document.write(opentags+"时间已经过了!"+closetags)
document.countdownnsmain.document.countdownnssub.document.close()
}
else if (document.all||document.getElementById)
crosscount.innerHTML=opentags+"Occasion already passed! "+closetags
return
}
else{
if (document.layers){
document.countdownnsmain.document.countdownnssub.document.write(opentags+dday+ " days, "+dhour+" hours, "+dmin+" minutes, and "+dsec+" seconds left until "+occasion+closetags)
document.countdownnsmain.document.countdownnssub.document.close()
}
else if (document.all||document.getElementById)
crosscount.innerHTML=opentags+"还有 "+dday+ " 天, "+dhour+" 小时, "+dmin+" 分, "+dsec+" 秒 就是 "+occasion+closetags
}
setTimeout("countdown()",1000)
}
</SCRIPT>
<ILAYER id=countdownnsmain visibility="hide" bgColor="&{countdownbgcolor};"
height="&{countdownheight};" width="&{countdownwidth};"><LAYER
id=countdownnssub height="&{countdownheight};"
width="&{countdownwidth};" top="0" left="0"></LAYER></ILAYER>

2006-09-27 20:34
oヤ偽妳變壞
Rank: 2
等 级:新手上路
威 望:4
帖 子:2251
专家分:0
注 册:2006-3-19
收藏
得分:0 

html 实现飘动的字

<SCRIPT language=JavaScript1.2>
<!--


var message='编程中国';
var messagecolor='#000000'

//Enter number of seconds for message to display (0=perpetual)
var dismissafter=0

///no need to edit below/////////
var amount=5,ypos=0,xpos=0,Ay=0,Ax=0,By=0,Bx=0,Cy=0,Cx=0,Dy=0,Dx=0,Ey=0,Ex=0;
if (document.layers){
for (i = 0; i < amount; i++)
{document.write('<layer name=ns'+i+' top=0 left=0><font face="Courier New" size=3 color='+messagecolor+'>'+message+'</font></layer>')}
window.captureEvents(Event.MOUSEMOVE);
function nsmouse(evnt){xpos = evnt.pageX;ypos = evnt.pageY;makefollow()}
}
else if (document.all){
document.write("<div id='outer' style='position:absolute;top:0px;left:0px'>");
document.write("<div id='inner' style='position:relative'>");
for (i = 0; i < amount; i++)
{document.write('<div id="text"'+i+' style="position:absolute;top:0px;left:0px;font-family:Courier New;font-size:16px;color:'+messagecolor+'">'+message+'</div>')}
document.write("</div>");
document.write("</div>");
function iemouse(){ypos = document.body.scrollTop + event.y;xpos = document.body.scrollLeft + event.x;makefollow()}
}
function makefollow(){
if (document.layers){
document.layers["ns0"].top=ay;document.layers["ns0"].left=ax;
document.layers["ns1"].top=by;document.layers["ns1"].left=bx;
document.layers["ns2"].top=cy;document.layers["ns2"].left=cx;
document.layers["ns3"].top=Dy;document.layers["ns3"].left=Dx;
document.layers["ns4"].top=Ey;document.layers["ns4"].left=Ex;
}
else if (document.all){
outer.all.inner.all[0].style.pixelTop=ay;outer.all.inner.all[0].style.pixelLeft=ax;
outer.all.inner.all[1].style.pixelTop=by;outer.all.inner.all[1].style.pixelLeft=bx;
outer.all.inner.all[2].style.pixelTop=cy;outer.all.inner.all[2].style.pixelLeft=cx;
outer.all.inner.all[3].style.pixelTop=Dy;outer.all.inner.all[3].style.pixelLeft=Dx;
outer.all.inner.all[4].style.pixelTop=Ey;outer.all.inner.all[4].style.pixelLeft=Ex;
}
}
function move(){
if (dismissafter!=0)
setTimeout("hidetrail()",dismissafter*1000)

if (document.layers){window.onMouseMove = nsmouse}
else if (document.all){window.document.onmousemove = iemouse}
ey = Math.round(Ey+=((ypos+20)-Ey)*2/2);ex = Math.round(Ex+=((xpos+20)-Ex)*2/2);
dy = Math.round(Dy+=(ey - Dy)*2/4);dx = Math.round(Dx+=(ex - Dx)*2/4);
cy = Math.round(Cy+=(dy - Cy)*2/6);cx = Math.round(Cx+=(dx - Cx)*2/6);
by = Math.round(By+=(cy - By)*2/8);bx = Math.round(Bx+=(cx - Bx)*2/8);
ay = Math.round(Ay+= (by - Ay)*2/10);ax = Math.round(Ax+= (bx - Ax)*2/10);
makefollow();
jumpstart=setTimeout('move()',10);
}

function hidetrail(){
if (document.all){
for (i2=0;i2<amount;i2++){
outer.all.inner.all[i2].style.visibility="hidden"
clearTimeout(jumpstart)
}
}
else if (document.layers){
for (i2=0;i2<amount;i2++){
temp="ns"+i2
document.layers[temp].visibility="hide"
clearTimeout(jumpstart)
}
}
}

window.onload=move;
//-->
</SCRIPT>

2006-09-27 20:36
huangyong
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:湖北武汉
等 级:版主
威 望:20
帖 子:603
专家分:7
注 册:2006-7-21
收藏
得分:0 
真服了你们!
硬把JS说成HTML......
2006-10-06 13:06
xlmm
Rank: 1
等 级:新手上路
帖 子:125
专家分:0
注 册:2006-10-6
收藏
得分:0 

是吗?我试了一下还不错


2006-10-24 22:45
快速回复:[分享]网页的一些效果——源码
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.018603 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved