网页特效代码
1、自动刷新网页
说明:自动刷新网页
在HTML的与之间加入下面这段代码,则在5分钟之后正在浏览的页面将会自动变为target.html这一页。代码中300为刷新的延迟时间,以秒为单位。targer.html为你想转向的目标页,若为本页则为自动刷新本页。
代码如下:
--------------------------------
<meta http-equiv="refresh" content="300; url=target.html">
-------------------------------------------------------
2、保护网页
说明:有些人真是懒得可以,把别人做好的网页往自己网页的框架(Frame)里一放,别人的成果就变成了自己的,而且看不出该网页的真实地址!为了防止你的成果被这些人所剽窃,你就可以在你网页的HTML里加入下面这段代码,这样,你的网页便总是在整个窗口中打开了。
代码如下:
--------------------------------
<Script LANGUAGE="javascript">
if(self!=top){top.location=self.location;}
</script>
-------------------------------------------------------
3、数字时钟
代码如下:
--------------------------------
<span id="liveclock" style"=width: 109px; height: 15px"></span>
<SCRIPT language=javascript>
function www_helpor_net()
{
var Digital=new Date()
var hours=Digital.getHours()
var minutes=Digital.getMinutes()
var seconds=Digital.getSeconds()
if(minutes<=9)
minutes="0"+minutes
if(seconds<=9)
seconds="0"+seconds
myclock="现在时刻:<font size="5" face="Arial black">"+hours+":"+minutes+":"+seconds+"</font>"
if(document.layers){document.layers.liveclock.document.write(myclock)
document.layers.liveclock.document.close()
}else if(document.all)
liveclock.innerHTML=myclock
setTimeout("www_helpor_net()",1000)
}
www_helpor_net();
//-->
</SCRIPT>
-------------------------------------------------------
4、中文时钟
代码如下:
--------------------------------
<script language="javascript">
<!--
function number(index1){
var numberstring="一二三四五六七八九十";
if(index1 ==0) {document.write("十")}
if(index1 < 10){
document.write(numberstring.substring(0+(index1-1),index1))}
else if(index1 < 20 ){
document.write("十"+numberstring.substring(0+(index1-11),(index1-10)))}
else if(index1 < 30 ){
document.write("二十"+numberstring.substring(0+(index1-21),(index1-20)))}
else{
document.write("三十"+numberstring.substring(0+(index1-31),(index1-30)))}
}
var today1 = new Date()
var month = today1.getMonth()+1
var date = today1.getDate()
var day = today1.getDay()
document.write("公元二零零二年")
number(month)
document.write("月")
number(date)
document.write("日")
//-->
</script>
-------------------------------------------------------
5、显示停留时间
显示他人在页面停留的时间,而且可以作出提醒
代码如下:
--------------------------------
您在本站逗留了<input type="text" name="china6u6_com" size="15" style="border: 0 ">
<SCRIPT language="javascript">
<!--
var sec=0;
var min=0;
var hou=0;
flag=0;
idt=window.setTimeout("www_helpor_net();",1000);
function www_helpor_net()
{
sec++;
if(sec==60){sec=0;min+=1;}
if(min==60){min=0;hou+=1;}
if((min>0)&&(flag==0))
{
window.alert("您刚刚来了1分钟!可别急着走开,还有好多好东东等着您呢!--站长");
flag=1;
}
helpor_net.value=hou+"小时"+min+"分"+sec+"秒";
idt=window.setTimeout("www_china6u6_com();",1000);
}
//-->
</SCRIPT>
-------------------------------------------------------
6、显示雪花飘飘
看到了吗,雪花图片自己添加!
代码如下:
--------------------------------
<SCRIPT LANGUAGE="javascript1.2">
<!--
var no = 12;
var speed = 10;
var heart = "snow.gif";
var flag;
var ns4up = (document.layers) ? 1 : 0;
var ie4up = (document.all) ? 1 : 0;
var dx, xp, yp;
var am, stx, sty;
var i, doc_width = 800, doc_height = 600;
if (ns4up) {
doc_width = self.innerWidth;
doc_height = self.innerHeight;
} else if (ie4up) {
doc_width = document.body.clientWidth;
doc_height = document.body.clientHeight;
}
dx = new Array();
xp = new Array();
yp = new Array();
amx = new Array();
amy = new Array();
stx = new Array();
sty = new Array();
flag = new Array();
for (i = 0; i < no; ++ i) {
dx = 0; // set coordinate variables
xp = Math.random()*(doc_width-30)+10;
yp = Math.random()*doc_height;
amy = 12+ Math.random()*20;
amx = 10+ Math.random()*40;
stx = 0.02 + Math.random()/10;
sty = 0.7 + Math.random();
flag = (Math.random()>0.5)?1:0;
if (ns4up) { // set layers
if (i == 0) {
document.write("<layer name="dot"+ i +"" left="15" ");
document.write("top="15" visibility="show"><img src="");
document.write(heart+ "" border="0"></layer>");
} else {
document.write("<layer name="dot"+ i +"" left="15" ");
document.write("top="15" visibility="show"><img src="");
document.write(heart+ "" border="0"></layer>");
}
} else
if (ie4up) {
if (i == 0) {
document.write("<div id="dot"+ i +"" style="POSITION: ");
document.write("absolute; Z-INDEX: "+ i +"; VISIBILITY: ");
document.write("visible; TOP: 15px; LEFT: 15px;"><img src="");
document.write(heart+ "" border="0"></div>");
} else {
document.write("<div id="dot"+ i +"" style="POSITION: ");
document.write("absolute; Z-INDEX: "+ i +"; VISIBILITY: ");
document.write("visible; TOP: 15px; LEFT: 15px;"><img src="");
document.write(heart+ "" border="0"></div>");
}
}
}
function helpor_net() {
for (i = 0; i < no; ++ i) {
if (yp > doc_height-50) {
xp = 10+ Math.random()*(doc_width-amx-30);
yp = 0;
flag=(Math.random()<0.5)?1:0;
stx = 0.02 + Math.random()/10;
sty = 0.7 + Math.random();
doc_width = self.innerWidth;
doc_height = self.innerHeight;
}
if (flag)
dx += stx;
else
dx -= stx;
if (Math.abs(dx) > Math.PI) {
yp+=Math.abs(amy*dx);
xp+=amx*dx;
dx=0;
flag=!flag;
}
document.layers["dot"+i].top = yp + amy*(Math.abs(Math.sin(dx)+dx));
document.layers["dot"+i].left = xp + amx*dx;
}
setTimeout("helpor_net()", speed);
}
function www_helpor_net() {
for (i = 0; i < no; ++ i) {
if (yp > doc_height-50) {
xp = 10+ Math.random()*(doc_width-amx-30);
yp = 0;
stx = 0.02 + Math.random()/10;
sty = 0.7 + Math.random();
flag=(Math.random()<0.5)?1:0;
doc_width = document.body.clientWidth;
doc_height = document.body.clientHeight;
}
if (flag)
dx += stx;
else
dx -= stx;
if (Math.abs(dx) > Math.PI) {
yp+=Math.abs(amy*dx);
xp+=amx*dx;
dx=0;
flag=!flag;
}
document.all["dot"+i].style.pixelTop = yp + amy*(Math.abs(Math.sin(dx)+dx));
document.all["dot"+i].style.pixelLeft = xp + amx*dx;
}
setTimeout("www_helpor_net()", speed);
}
if (ns4up) {
helpor_net();
} else if (ie4up) {
www_helpor_net();
}
//-->
</script>
-------------------------------------------------------
7、显示访客登陆次数
记录访客的来访次数,并根据作出不同的提示信息! 代码如下:
--------------------------------
<SCRIPT language="javascript">
<!--
function www_helpor_net(offset)
{
var endstr=documents.cookie.indexOf(";",offset);if(endstr==-1)
endstr=documents.cookie.length;return unescape(documents.cookie.substring(offset,endstr));}
function GetCookie(name)
{
var arg=name+"=";
var alen=arg.length;
var clen=documents.cookie.length;
var i=0;while(i<clen)
{
var j=i+alen;
if(documents.cookie.substring(i,j)==arg)
return www_helpor_net(j);
i=documents.cookie.indexOf(" ",i)+1;if(i==0)
break;
}
return null;
}
function SetCookie(name,value)
{
var argv=SetCookie.arguments;
var argc=SetCookie.arguments.length;
var expires=(2<argc)?argv[2]:null;
var path=(3<argc)?argv[3]:null;
var domain=(4<argc)?argv[4]:null;
var secure=(5<argc)?argv[5]:false;
documents.cookie=name+"="+escape(value)+((expires==null)?"" "; expires="+expires.toGMTString()))+((path==null)?"" "; path="+path))+((domain==null)?"" "; domain="+domain))+((secure==true)?"; secure":"");
}
var expdate=new Date();
var visits;
expdate.setTime(expdate.getTime()+(24*60*60*1000*365)); //设置COOKIES时间为1年,自己随便设置该时间
if(!(visits=GetCookie("visits")))
visits=0;visits++;SetCookie("visits",visits,expdate,"/",null,false);
//以下信息显示可以使用标准的HTML语法,自己随便设置
document.write("你已经光临本页"+"<FONT COLOR=red>"+visits+"</FONT>"+"次!");
if(visits==1)//来访1次的信息显示
document.write("<br>"+"欢迎光临本站,觉得本站内容如何?");
if(visits==2)//来访2次的信息显示,以下类推,自己随便增加
document.write("<br>"+"再次光临不胜容幸!今后要常来啊!欢迎点击本站广告。");
if(visits==3)
document.write("<br>"+"常客,在本站的论坛发个帖子如何?");
if(visits==4)
document.write("<br>"+"你这个疯子!");
if(visits>=5)
document.write("<br>"+"疯狂的家伙!我真的非常喜欢你。");
//-->
</SCRIPT>
-------------------------------------------------------
8、礼花背景
实例: 看到了吗
代码:
将以下代码加入HEML的<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,1,1"></layer>
<layer name="a8" left=10 top=10 visibility=show bgcolor="#fff000" clip="0,0,1,1"></layer>
<layer name="a9" left=10 top=10 visibility=show bgcolor="#ffa000" clip="0,0,1,1"></layer>
<layer name="a10" left=10 top=10 visibility=show bgcolor="#ff00ff" clip="0,0,1,1"></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>
<div id="starsDiv" style="position:absolute;top:0px;left:0px">
<div style="position:relative;width:4px;height:4px;background:#ffffff;font-size:4px"></div>
<div style="position:relative;width:2px;height:2px;background:#fff000;font-size:2px"></div>
<div style="position:relative;width:2px;height:2px;background:#ffa000;font-size:2px"></div>
<div style="position:relative;width:2px;height:2px;background:#ff00ff;font-size:2px"></div>
<div style="position:relative;width:2px;height:2px;background:#00ff00;font-size:2px"></div>
<div style="position:relative;width:2px;height:2px;background:#0000ff;font-size:2px"></div>
<div style="position:relative;width:2px;height:2px;background:#FF0000;font-size:2px"></div>
<div style="position:relative;width:2px;height:2px;background:#ffffff;font-size:2px"></div>
<div style="position:relative;width:2px;height:2px;background:#fff000;font-size:2px"></div>
<div style="position:relative;width:2px;height:2px;background:#ffa000;font-size:2px"></div>
<div style="position:relative;width:2px;height:2px;background:#ff00ff;font-size:2px"></div>
<div style="position:relative;width:4px;height:4px;background:#ff00ff;font-size:4px"></div>
<div style="position:relative;width:2px;height:2px;background:#0000ff;font-size:2px"></div>
<div style="position:relative;width:2px;height:2px;background:#FF0000;font-size:2px"></div>
</div>
<SCRIPT LANGUAGE="javascript">
<!-- Begin
var Clrs = new Array(9);
Clrs[0] = "ff0000";
Clrs[1] = "00ff00";
Clrs[2] = "000aff";
Clrs[3] = "ff00ff";
Clrs[4] = "ffa500";
Clrs[5] = "ffff00";
Clrs[6] = "00ff00";
Clrs[7] = "ffffff";
Clrs[8] = "fffff0";
var sClrs = new Array(5);
sClrs[0] = "ffa500";
sClrs[1] = "55ff66";
sClrs[2] = "AC9DFC";
sClrs[3] = "fff000";
sClrs[4] = "fffff0";
var yBase;
var xBase;
var step;
var currStep = 0;
var Xpos = 1;
var Ypos = 1;
var initialStarColor = "ffa000";
var Mtop = 250;
var Mleft = 250;
function Fireworks() {
if (document.all) {
yBase = window.document.body.offsetHeight / 3;
xBase = window.document.body.offsetWidth / 8;
}
else if (document.layers) {
yBase = window.innerHeight / 3;
xBase = window.innerWidth / 8;
}
if (document.all) {
step = 5;
for ( i = 0 ; i < starsDiv.all.length ; i++ ) {
for (ai = 0; ai < Clrs.length; ai++) {
var c = Math.round(Math.random()*[ai]);
}
if (currStep < 90)
starsDiv.all.style.background=initialStarColor;
if (currStep > 90)
starsDiv.all.style.background=Clrs[c];
starsDiv.all.style.top = Mtop + yBase*Math.sin((currStep+i*5)/3)*Math.sin(550+currStep/100)
starsDiv.all.style.left = Mleft + yBase*Math.cos((currStep+i*5)/3)*Math.sin(550+currStep/100)
}
}
else if (document.layers) {
step = 5;
for ( j = 0 ; j < 24 ; j++ ) { //number of NS layers!
var templayer = "a"+j;
for (ai = 0; ai < Clrs.length; ai++) {
var c = Math.round(Math.random()*[ai]);
}
if (currStep < 90)
document.layers[templayer].bgColor=initialStarColor;
if (currStep > 90)
document.layers[templayer].bgColor=Clrs[c];
document.layers[templayer].top = Mtop + yBase*Math.sin((currStep+j*5)/3)*Math.sin(550+currStep/100)
document.layers[templayer].left = Mleft + yBase*Math.cos((currStep+j*5)/3)*Math.sin(550+currStep/100)
}
}
currStep+= step;
T=setTimeout("Fireworks()",5);
if (currStep == 220) {
currStep = -10;
for (n = 0; n < sClrs.length; n++) {
var k = Math.round(Math.random()*n);
}
initialStarColor = sClrs[k];
if (document.all) {
Dtop = window.document.body.clientHeight - 250;
Dleft = xBase * 3.5;
Mtop = Math.round(Math.random()*Dtop);
Mleft = Math.round(Math.random()*Dleft);
document.all.starsDiv.style.top = Mtop+document.body.scrollTop;
document.all.starsDiv.style.left = Mleft+document.body.scrollLeft;
}
else if (document.layers) {
Dleft = window.innerWidth - 100;
Dtop = window.innerHeight - 100;
Mtop = Math.round(Math.random()*Dtop+window.pageYOffset);
Mleft = Math.round(Math.random()*Dleft+window.pageXOffset);
document.layers[templayer].top = Mtop;
document.layers[templayer].left = Mleft;
}
if ((Mtop < 20) ││ (Mleft < 20)) {
Mtop += 90;
Mleft += 90;
}
}
}
Fireworks();
// End -->
</script>
|