【web技术】html特效代码(二)
图片漂浮广告代码
-
<bodybgcolor="#F7F7F7">
-
<!--图片漂浮广告代码开始-->
-
<divid="www_qpsh_com"style="position:absolute">
-
<!--链接地址--><ahref="www.baidu.com"_fcksavedurl="/"target="_blank">
-
<!--图片地址--><imgsrc="http://www.baidu.com"_fcksavedurl="http://www.dabaoku.com/images/logo.gif"border="0">
-
</a>
-
</div>
-
<script>
-
var x = 50,y = 60
-
var xin = true, yin = true
-
var step = 1
-
var delay = 10
-
var obj=document.getElementById("www_qpsh_com")
-
function floatwww_qpsh_com() {
-
var L=T=0
-
//by www.qpsh.com
-
var R= document.body.clientWidth-obj.offsetWidth
-
var B = document.body.clientHeight-obj.offsetHeight
-
obj.style.left = x + document.body.scrollLeft
-
obj.style.top = y + document.body.scrollTop
-
xx = x + step*(xin?1:-1)
-
if (x <L) { xin = true; x = L}
-
if (x > R){ xin = false; x = R}
-
yy = y + step*(yin?1:-1)
-
if (y <T) { yin = true; y = T }
-
if (y > B) { yin = false; y = B }
-
}
-
var itl= setInterval("floatwww_qpsh_com()", delay)
-
obj.onmouseover=function(){clearInterval(itl)}
-
obj.onmouseout=function(){itl=setInterval("floatwww_qpsh_com()", delay)}
-
</script>
-
<!--图片漂浮广告代码结束-->
-
</body>
围绕鼠标的立体旋转文字
-
<html>
-
<head>
-
<title>围绕鼠标的立体旋转文字</title>
-
<metacontent="text/html; charset=gb2312"http-equiv="Content-Type">
-
<metacontent="Microsoft FrontPage 5.0"name="GENERATOR">
-
</head>
-
<body>
-
<scriptLANGUAGE="JavaScript">
-
<!-- Begin
-
if (document.all) {
-
yourLogo = "百家联盟欢迎你"; //Not less than 2 letters!
-
logoFont = "Arial";
-
logoColor = "ff0000";
-
//Nothing needs altering below!
-
yourLogoyourLogo = yourLogo.split('');
-
L = yourLogo.length;
-
TrigSplit = 360 / L;
-
Sz = new Array()
-
logoWidth = 100;
-
logoHeight = -30;
-
ypos = 0;
-
xpos = 0;
-
step = 0.09;
-
currStep = 0;
-
document.write('<divid="outer"style="position:absolute;top:0px;left:0px"><divstyle="position:relative">');
-
for (i = 0; i <L; i++) {
-
document.write('<divid="ie"style="position:absolute;top:0px;left:0px;'
-
+'width:10px;height:10px;font-family:'+logoFont+';font-size:12px;'
-
+'color:'+logoColor+';text-align:center">'+yourLogo[i]+'</div>');
-
}
-
document.write('</div></div>');
-
function Mouse() {
-
ypos = event.y;
-
xpos = event.x - 5;
-
}
-
document.onmousemove=Mouse;
-
function animateLogo() {
-
outer.style.pixelTop = document.body.scrollTop;
-
for (i = 0; i <L; i++) {
-
ie[i].style.top = ypos + logoHeight * Math.sin(currStep + i * TrigSplit * Math.PI / 180);
-
ie[i].style.left = xpos + logoWidth * Math.cos(currStep + i * TrigSplit * Math.PI / 180);
-
Sz[i] = ie[i].style.pixelTop - ypos;
-
if (Sz[i] <5) Sz[i] = 5;
-
ie[i].style.fontSize = Sz[i] / 1.7;
-
}
-
currStep -= step;
-
setTimeout('animateLogo()', 20);
-
}
-
window.onload = animateLogo;
-
}
-
// End -->
-
</script>
-
</body>
-
</html>
文本特效-打字效果的网站公告
-
<html>
-
<head>
-
<title>网页特效-文本特效-打字效果的网站公告</title>
-
<FCK:metahttp-equiv="content-Type"content="text/html;charset=gb2312"/>
-
<body>
-
<!--把下面代码加到<body>与</body>之间-->
-
百晓生说明:<aid="HotNews"href=""_fcksavedurl=""target="_blank"></a>
-
<scriptlanguage="javascript">
-
<!--
-
var NewsTime = 2000;//每条新闻的停留时间
-
var TextTime = 50; //新闻标题文字出现等待时间,越小越快
-
var newsi = 0;
-
var txti = 0;
-
var txttimer;
-
var newstimer;
-
var newnewstitle = new Array();//新闻标题
-
var newnewshref = new Array(); //新闻链接
-
newstitle[0] = "关于百晓生,大家都比较熟的了、呵呵,如果有想了解的就直接去我的暂住小站哈,http://infodown.tap.cn,欢迎来访,欢迎留言";
-
newshref[0] = "http://infodown.tap.cn";
-
-
function shownew()
-
{
-
var endstr = "_"
-
hwnewstr = newstitle[newsi];
-
newslink = newshref[newsi];
-
if(txti==(hwnewstr.length-1)){endstr="";}
-
if(txti>=hwnewstr.length){
-
clearInterval(txttimer);
-
clearInterval(newstimer);
-
newsi++;
-
if(newsi>=newstitle.length){
-
newsi = 0
-
}
-
newstimer = setInterval("shownew()",NewsTime);
-
txti = 0;
-
return;
-
}
-
clearInterval(txttimer);
-
document.getElementById("HotNews").href=newslink;
-
document.getElementById("HotNews").innerHTML = hwnewstr.substring(0,txti+1)+endstr;
-
txti++;
-
txttimer = setInterval("shownew()",TextTime);
-
}
-
shownew();
-
//-->
-
</script>
-
</body>
-
</html>
无法屏蔽的网页右下角浮动窗口
-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-
<htmlxmlns="http://www.w3.org/1999/xhtml">
-
<head>
-
<title>无法屏蔽的网页右下角浮动窗口</title>
-
<metahttp-equiv="content-type"content="text/html;charset=gb2312">
-
<styletype="text/css">
-
#msg_win{border:1px solid #A67901;background:#EAEAEA;width:240px;position:absolute;right:0;font-size:12px;font-family:Arial;margin:0px;display:none;overflow:hidden;z-index:99;}
-
#msg_win .icos{position:absolute;top:2px;*top:0px;right:2px;z-index:9;}
-
.icos a{float:left;color:#833B02;margin:1px;text-align:center;font-weight:bold;width:14px;height:22px;line-height:22px;padding:1px;text-decoration:none;font-family:webdings;}
-
.icos a:hover{color:#fff;}
-
#msg_title{background:#FECD00;border-bottom:1px solid #A67901;border-top:1px solid #FFF;border-left:1px solid #FFF;color:#000;height:25px;line-height:25px;text-indent:5px;}
-
#msg_content{margin:5px;margin-right:0;width:230px;height:126px;overflow:hidden;}
-
</style>
-
</head>
-
<body>
-
<pstyle="height:1000px;"></p>
-
<divid="msg_win"style="display:block;top:490px;visibility:visible;opacity:1;">
-
<divclass="icos"><aid="msg_min"title="最小化"href="void 0"< /span>>_</a><aid="msg_close"title="关闭"href="void 0"< /span>>×</a></div>
-
<divid="msg_title">网页制作大宝库</div>
-
<divid="msg_content">网页制作大宝库dabaoku.com</div>
-
</div>
-
<scriptlanguage="javascript">
-
var Message={
-
set: function() {//最小化与恢复状态切换
-
var set=this.minbtn.status == 1?[0,1,'block',this.char[0],'最小化']:[1,0,'none',this.char[1],'恢复'];
-
this.minbtn.status=set[0];
-
this.win.style.borderBottomWidth=set[1];
-
this.content.style.display =set[2];
-
this.minbtn.innerHTML =set[3]
-
this.minbtn.title = set[4];
-
thisthis.win.style.top = this.getY().top;
-
},
-
close: function() {//关闭
-
this.win.style.display = 'none';
-
window.onscroll = null;
-
},
-
setOpacity: function(x) {//设置透明度
-
var v = x>= 100 ? '': 'Alpha(opacity=' + x + ')';
-
this.win.style.visibility = x<=0?'hidden':'visible';//IE有绝对或相对定位内容不随父透明度变化的bug
-
this.win.style.filter = v;
-
this.win.style.opacity = x / 100;
-
},
-
show: function() {//渐显
-
clearInterval(this.timer2);
-
var me = this,fx = this.fx(0, 100, 0.1),t = 0;
-
this.timer2 = setInterval(function() {
-
t = fx();
-
me.setOpacity(t[0]);
-
if (t[1] == 0) {clearInterval(me.timer2) }
-
},10);
-
},
-
fx: function(a, b, c) {//缓冲计算
-
var cMath = Math[(a - b) > 0 ? "floor": "ceil"],cc = c || 0.1;
-
return function() {return [a += cMath((b - a) * c), a - b]}
-
},
-
getY: function() {//计算移动坐标
-
var d = document,b = document.body, e = document.documentElement;
-
var s = Math.max(b.scrollTop, e.scrollTop);
-
var h = /BackCompat/i.test(document.compatMode)?b.clientHeight:e.clientHeight;
-
var h2 = this.win.offsetHeight;
-
return {foot: s + h + h2 + 2+'px',top: s + h - h2 - 2+'px'}
-
},
-
moveTo: function(y) {//移动动画
-
clearInterval(this.timer);
-
var me = this,a = parseInt(this.win.style.top)||0;
-
var fx = this.fx(a, parseInt(y));
-
var t = 0 ;
-
this.timer = setInterval(function() {
-
t = fx();
-
me.win.style.top = t[0]+'px';
-
if (t[1] == 0) {
-
clearInterval(me.timer);
-
me.bind();
-
}
-
},10);
-
},
-
bind:function (){//绑定窗口滚动条与大小变化事件
-
var me=this,st,rt;
-
window.onscroll = function() {
-
clearTimeout(st);
-
clearTimeout(me.timer2);
-
me.setOpacity(0);
-
st = setTimeout(function() {
-
meme.win.style.top = me.getY().top;
-
me.show();
-
},600);
-
};
-
window.onresize = function (){
-
clearTimeout(rt);
-
rt = setTimeout(function() {meme.win.style.top = me.getY().top},100);
-
}
-
},
-
init: function() {//创建HTML
-
function $(id) {return document.getElementById(id)};
-
this.win=$('msg_win');
-
var set={minbtn: 'msg_min',closebtn: 'msg_close',title: 'msg_title',content: 'msg_content'};
-
for (var Id in set) {this[Id] = $(set[Id])};
-
var me = this;
-
this.minbtn.onclick = function() {me.set();this.blur()};
-
this.closebtn.onclick = function() {me.close()};
-
this.char=navigator.userAgent.toLowerCase().indexOf('firefox')+1?['_','::','×']:['0','2','r'];//FF不支持webdings字体
-
thisthis.minbtn.innerHTML=this.char[0];
-
thisthis.closebtn.innerHTML=this.char[2];
-
setTimeout(function() {//初始化最先位置
-
me.win.style.display = 'block';
-
meme.win.style.top = me.getY().foot;
-
me.moveTo(me.getY().top);
-
},0);
-
return this;
-
}
-
};
-
Message.init();
-
</script>
-
</body>
-
</html>
本文出自 “成鹏致远” 博客,请务必保留此出处http://infohacker.blog.51cto.com/6751239/1171465