我的收藏!(一些常用的函数)

llrock 2002-09-07 04:25:03
不好意思学人家授人予渔,我认为使用这些函数足可以制作出各种特效。我就是这么做的,现在送给大家。(因为心情不好,面临很多债务,more than 2M¥,烦死了,我还很年轻的,以后怎么过)

1、为了提高适用性,检查浏览器版本

function lib_bwcheck(){ this.ver=navigator.appVersion;
this.agent=navigator.userAgent
this.dom=document.getElementById?1:0
this.win = (navigator.appVersion.indexOf("Win")>0);
this.xwin = (navigator.appVersion.indexOf("X11")>0);
this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0;
this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom)?1:0;
this.ie4=(document.all && !this.dom)?1:0;
this.ie=this.ie4||this.ie5||this.ie6
this.mac=this.agent.indexOf("Mac")>-1
this.opera5=this.agent.indexOf("Opera 5")>-1
this.ns6=(this.dom && parseInt(this.ver) >= 5) ?1:0;
this.ns4=(document.layers && !this.dom)?1:0;
this.bw=(this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.opera5 || this.dom||false);
this.width = null;
this.height = null;
return this
}

例如 var bw = new lib_bwcheck();//指需要实例一个bw,建议bw,因为后面的函数中我使用bw检查浏览器

2、一个层的“类”,包含了一些常用的方法和属性
function oLayer( idStr ) {
this.idStr = idStr;
if(bw.ns4)this.idPtr=document.layers[idStr];
else if (bw.ns6) this.idPtr = document.getElementById(idStr);
else this.idPtr = eval('document.all.'+idStr);
//----------方法-------
//this.makeAnimate = makeAnimate; //用于产生移动图层的动画效果
this.moveTo=lib_moveTo;
this.moveBy=lib_moveBy;
this.clipTo=lib_clipTo;
this.show=lib_showIt;
this.hide=lib_hideIt;
this.zoomTo=lib_zoomTo; //缩放图层
this.setBgColor=lib_setBgC;
//---------属性-------
this.x = getLayerX(this.idStr);
this.y = getLayerY(this.idStr);
this.z = getZIndex(this.idStr);
this.sh = getLayerSH(this.idStr);
this.sw = getLayerSW(this.idStr);
if (bw.ns6) this.css=this.idPtr.style;
else if (bw.ns) this.css=this.idPtr;
else this.css=this.idPtr.style;

return (this);
}



function lib_clipTo(t,r,b,l,setwidth){ //改变图层大小
if(t<0)t=0;
if(r<0)r=0;
if(b<0)b=0;
if(l<0)l=0;
this.ct=t;
this.cr=r;
this.cb=b;
this.cl=l
if(bw.ns4){
this.css.clip.top=t;
this.css.clip.right=r;
this.css.clip.bottom=b;
this.css.clip.left=l;
}else if(bw.opera5){
this.css.pixelWidth=r;
this.css.pixelHeight=b;
this.w=r;
this.h=b
}else{
this.css.clip="rect("+t+","+r+","+b+","+l+")";
if(setwidth){
this.css.width=r;
this.css.height=b;
this.w=r;
this.h=b
}
}
}
function lib_zoomTo(scale){
this.scale=scale;
this.css.zoom=scale;
}

function lib_moveTo(x,y){
this.x=x!=''?x:this.x;
this.y=y!=''?y:this.y;
this.css.left=this.x;
this.css.top=this.y
}

function lib_moveBy(x,y){
this.moveTo(this.x+x,this.y+y)
}

function lib_showIt(){
this.css.visibility="visible";
this.visible=true;
}

function lib_hideIt(){
this.css.visibility="hidden";
this.visible=false;
}

function lib_setBgC(color){
if(bw.opera5) this.css.background=color;
else if(bw.dom || bw.ie4||bw.ns6) this.css.backgroundColor=color;
else if(bw.ns4) this.css.bgColor=color ;
}
例如:oWin=new oLayer('层id'),那么要移动层到(100,200)就可以oWin.moveTo(100,200);而不需要再检查浏览器类型
...全文
38 27 打赏 收藏 转发到动态 举报
写回复
用AI写文章
27 条回复
切换为时间正序
请发表友善的回复…
发表回复
lmh79 2002-10-14
  • 打赏
  • 举报
回复
收藏
Reker熊 2002-09-12
  • 打赏
  • 举报
回复
很棒哦

收藏!
llrock 2002-09-12
  • 打赏
  • 举报
回复
http://www.csdn.net/expert/topic/871/871206.xml?temp=.413418

这是我做的一个菜单,使用了上面大多数函数,并且加了那个动画的演示,看看就知道了。
bian8021 2002-09-12
  • 打赏
  • 举报
回复
收藏
lirc 2002-09-12
  • 打赏
  • 举报
回复
怎么调用那个层的动画啊?
谢谢。
lirc 2002-09-12
  • 打赏
  • 举报
回复
up
shentj 2002-09-12
  • 打赏
  • 举报
回复
太阳总会出来的,努力啊
richardluopeng 2002-09-09
  • 打赏
  • 举报
回复
谢谢!
qimangxing 2002-09-09
  • 打赏
  • 举报
回复
多谢搂主,收藏起来先,相信好人一帆风顺!!!
redblues 2002-09-08
  • 打赏
  • 举报
回复
收藏!祝你每天开心多一点!
神鹰 2002-09-08
  • 打赏
  • 举报
回复
也祝你有好运,早日摆脱困境.

加入收藏
jo_yoko 2002-09-08
  • 打赏
  • 举报
回复
收藏啦!愿楼主早日摆脱债务!
emu 2002-09-08
  • 打赏
  • 举报
回复
虱多不痒,债多不愁啊。收藏收藏。
flashasp 2002-09-08
  • 打赏
  • 举报
回复
mark!
upup!
llrock 2002-09-07
  • 打赏
  • 举报
回复
一个进度条,这个进度条可以提前把你将要用到的图片(因为一般图片占用了大量资源)提前读到本地,然后重定向到下一页。这个进度条比较准确的显示了进度,和其他的进度条比较一下就知道了。

=============================================
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
</HEAD>

<BODY>
<SCRIPT LANGUAGE="JavaScript">
<!--
function imgGauge(imgArr){ //v3.0
var ready=true;
var bgc='#9999cc'; //进度条被景色
var okc='#888888'; //进度颜色
var fontc='#000000'; //字体颜色
var w=200; //进度条宽度
var h=15; //高度
var yyhide=false;
var yyshowpc=true;
var redirection="mainF.htm";//所有图片预读结束后重定向到指定页

if (document.images)with (document){
if (document.preloadArray==null){//first call the function
document.preloadArray = new Array();
for(i=0;i<imgs.length;++i){
preloadArray[i] = new Image;
preloadArray[i].src =imgs[i];
}
}
if(document.preloadArray){
var howmany=0;
for(var i=0;i<preloadArray.length;++i){
ready = ready && preloadArray[i].complete;
if (preloadArray[i].complete)++howmany;
}
var suc=Math.round(howmany*100/preloadArray.length);
pos=Math.round(howmany/preloadArray.length*w);
htmlcode='<body><table width='+w+' height="'+h+'" bgcolor='+bgc+' border=0 cellpadding=0 cellspacing=0><tr><td bgcolor='+okc+' width='+pos+'></td><td width='+(w-pos)+'></td></tr></table>';
if (yyshowpc)htmlcode+='<center><font size=1 face="sans-serif" color="'+fontc+'">'+suc+'%</font></center>';
htmlcode+='</body>';
document.all['schedule'].innerHTML=htmlcode;
if ((ready)&&(yyhide))setTimeout('document.all[\'schedule\'].style.visibility="hidden"',1000);

if(ready){
if(redirection!='#')document.location=redirection;
}else{
setTimeout('imgGauge()',50);
}
}else{
setTimeout('imgGauge()',1000)
}
}
}

//这是必需的,把你准备预读到本地的图片放到数组中,注意文件名拼写正确
var imgs=['img/bg.gif','img/bgh.gif','img/open_l.gif','img/open_r.gif','img/apple.gif','img/jiaoL.gif','img/jiaoR.gif','img/face_s.gif','img/buttons_over.gif','img/buttons_out.gif','img/scroll_out.gif','img/scroll_over.gif','img/open_l.gif','img/open_r.gif','img/finder.gif','img/mail.gif','img/IE.gif','img/music.gif','img/action.gif','img/appleX_B.gif','img/register.gif','img/ball.gif','img/color.gif','img/close_over.gif','img/close_out.gif','img/page_out.gif','img/page_over_l.gif','img/page_over_r.gif','img/counts.gif'];


//
//-->
</script>
</head>
<body bgcolor="#7270BC" background="back1.jpg" text="#000000" link="#000000" vlink="#000033" alink="#000033" scroll=no onLoad=" imgGauge(imgs);">
<!-- schedule bar -->
<div id="schedule" style="position:absolute; width:200; height:36; z-index:100; left: 328px; top: 55px; overflow: hidden; visibility: visible">
</div>
</body>
</html>
============================================
∧ ∧
( ⊙_⊙ ) 祝所有人好运!我会天天Happy的。
vivanboy 2002-09-07
  • 打赏
  • 举报
回复

不要新开帖了。一帖有利于收藏

收藏
Lostinet 2002-09-07
  • 打赏
  • 举报
回复
2M¥是两蚊?
wjmmml 2002-09-07
  • 打赏
  • 举报
回复
收藏
zhiwen_huang 2002-09-07
  • 打赏
  • 举报
回复
Ha Ha...

Happy everyday
zhiwen_huang 2002-09-07
  • 打赏
  • 举报
回复
I have 40,000RMB & 1000$,
do you want to it?
加载更多回复(7)

87,996

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧