3、上面的函数必须基于你创建的对象,下面的函数可以随时调用:
function getBwSize() {//得到当前浏览器客户区域尺寸,存到全局的bw对象中
if (bw.compatible) {
if (bw.ie) {
bw.width = document.body.clientWidth;
bw.height = document.body.clientHeight;
}else if (bw.ns4) {
bw.width = window.innerWidth;
bw.height = window.innerHeight;
document.all = document;
}else if (bw.ns6) {
bw.width = window.innerWidth;
bw.height = window.innerHeight;
}else if(bw.opera) {
bw.width = window.innerWidth;
bw.height = window.innerHeight;
}
return (true);
}else {
alert('非常不幸的是你的浏览器或操作系统不支持我们目前的站点,你将被重定向到我的个人网站llrock.myrice.com');
location.href='http://llrock.myrice.com';
} }
function moveByIt( ID, x, y){//通过元素ID移动x,y个象素
if (bw.ns6) {
var thisID = document.getElementById(ID);
thisID.style.left = parseInt(thisID.style.left)+x;
thisID.style.top = parseInt(thisID.style.top)+y;
}else if (bw.ns) {
document.layers[ID].moveBy(x, y);
}else {
var thisID = document.all[ID];
thisID.style.pixelLeft = parseInt(thisID.style.pixelLeft)+x;
thisID.style.pixelTop = parseInt(thisID.style.pixelTop)+y;
}
}
function moveToIt( ID, x, y){//通过元素ID移动到(x,y)处
if (bw.ns6) {
var thisID = document.getElementById(ID);
thisID.style.left = x;thisID.style.top = y;
}else if (bw.ns) {
document.layers[ID].moveTo(x, y);
}else {
var thisID = document.all[ID];
thisID.style.pixelLeft = x;
thisID.style.pixelTop = y;
}
}
function resizeByIt( ID, w, h) {//通过元素ID尺寸增加w和h
if (bw.ns6) {
var thisID = document.getElementById(ID);
thisID.style.width = (parseInt(thisID.style.offsetWidth)+w+"px");
thisID.style.height = (parseInt(thisID.style.offsetHeight)+h+"px");
}else if (bw.ns) {
document.layers[ID].resizeBy(w,h);
}else {
var thisID = document.all[ID];
thisID.style.pixelWidth = thisID.offsetWidth+w;
thisID.style.pixelHeight = thisID.offsetHeight+h;
}
}
function resizeToIt( ID, w, h) {//通过元素ID尺寸改变到w,h
if (bw.ns6) {
var thisID = document.getElementById(ID);
thisID.style.width = w+"px";thisID.style.height = h+"px";
}else if (bw.ns) {
document.layers[ID].resizeTo(w,h);
document.layers[ID].document.width = w;
document.layers[ID].document.height = h;
}else {
var thisID = document.all[ID];
thisID.style.pixelWidth = w;
thisID.style.pixelHeight = h;
}
}
function getObjectById( ID ) {//通过元素ID得到对象实例,用于引用对象
if (bw.ns6) return document.getElementById(ID);
else if (bw.ns) return document.layers[ID];
else return document.all[ID];
}
function getLayerX( ID ) {
if (bw.ns6) return(parseInt(document.getElementById(ID).style.left));
else if (bw.ns) return(document.layers[ID].left);
else return(document.all[ID].offsetLeft);
}
function getLayerY( ID ) {
if (bw.ns6) return(parseInt(document.getElementById(ID).style.top));
else if (bw.ns) return(document.layers[ID].top);
else return(document.all[ID].offsetTop);
}
function getLayerSW( ID ) {
if (bw.ns6) {
if(isNaN(parseInt(document.getElementById(ID).style.width))) return(parseInt(document.defaultView.getComputedStyle(document.getElementById(ID),null).getPropertyValue('width')));
else if(parseInt(document.getElementById(ID).style.width)==0) return(parseInt(document.defaultView.getComputedStyle(document.getElementById(ID),null).getPropertyValue('width')));
else return(parseInt(document.getElementById(ID).style.width));
}else if (bw.ns) return(document.layers[ID].document.width);
else return(document.all[ID].scrollWidth);
}
function getLayerSH( ID ){
if (bw.ns6) {
if(isNaN(parseInt(document.getElementById(ID).style.height))) return(parseInt(document.defaultView.getComputedStyle(document.getElementById(ID),null).getPropertyValue('height')));
else if(parseInt(document.getElementById(ID).style.height)==0) return(parseInt(document.defaultView.getComputedStyle(document.getElementById(ID),null).getPropertyValue('height')));
else return(parseInt(document.getElementById(ID).style.height));
}else if (bw.ns) return(document.layers[ID].document.height);
else return(document.all[ID].scrollHeight);
}
function getLayerW( ID ) {
if (bw.ns6) return(parseInt(document.getElementById(ID).style.width));
else if (bw.ns) return(document.layers[ID].document.width);
else return(document.all[ID].offsetWidth);
}
function getLayerH( ID ){
if (bw.ns6) return(parseInt(document.getElementById(ID).style.height));
else if (bw.ns) return(document.layers[ID].document.height);
else return(document.all[ID].offsetHeight);
}
function getBwSize() {//得到当前浏览器客户区域尺寸,存到全局的bw对象中
if (bw.compatible) {
if (bw.ie) {
bw.width = document.body.clientWidth;
bw.height = document.body.clientHeight;
}else if (bw.ns4) {
bw.width = window.innerWidth;
bw.height = window.innerHeight;
document.all = document;
}else if (bw.ns6) {
bw.width = window.innerWidth;
bw.height = window.innerHeight;
}else if(bw.opera) {
bw.width = window.innerWidth;
bw.height = window.innerHeight;
}
return (true);
}else {
alert('非常不幸的是你的浏览器或操作系统不支持我们目前的站点,你将被重定向到我的个人网站llrock.myrice.com');
location.href='http://llrock.myrice.com';
} }
function moveByIt( ID, x, y){//通过元素ID移动x,y个象素
if (bw.ns6) {
var thisID = document.getElementById(ID);
thisID.style.left = parseInt(thisID.style.left)+x;
thisID.style.top = parseInt(thisID.style.top)+y;
}else if (bw.ns) {
document.layers[ID].moveBy(x, y);
}else {
var thisID = document.all[ID];
thisID.style.pixelLeft = parseInt(thisID.style.pixelLeft)+x;
thisID.style.pixelTop = parseInt(thisID.style.pixelTop)+y;
}
}
function moveToIt( ID, x, y){//通过元素ID移动到(x,y)处
if (bw.ns6) {
var thisID = document.getElementById(ID);
thisID.style.left = x;thisID.style.top = y;
}else if (bw.ns) {
document.layers[ID].moveTo(x, y);
}else {
var thisID = document.all[ID];
thisID.style.pixelLeft = x;
thisID.style.pixelTop = y;
}
}
function resizeByIt( ID, w, h) {//通过元素ID尺寸增加w和h
if (bw.ns6) {
var thisID = document.getElementById(ID);
thisID.style.width = (parseInt(thisID.style.offsetWidth)+w+"px");
thisID.style.height = (parseInt(thisID.style.offsetHeight)+h+"px");
}else if (bw.ns) {
document.layers[ID].resizeBy(w,h);
}else {
var thisID = document.all[ID];
thisID.style.pixelWidth = thisID.offsetWidth+w;
thisID.style.pixelHeight = thisID.offsetHeight+h;
}
}
function resizeToIt( ID, w, h) {//通过元素ID尺寸改变到w,h
if (bw.ns6) {
var thisID = document.getElementById(ID);
thisID.style.width = w+"px";thisID.style.height = h+"px";
}else if (bw.ns) {
document.layers[ID].resizeTo(w,h);
document.layers[ID].document.width = w;
document.layers[ID].document.height = h;
}else {
var thisID = document.all[ID];
thisID.style.pixelWidth = w;
thisID.style.pixelHeight = h;
}
}
function getObjectById( ID ) {//通过元素ID得到对象实例,用于引用对象
if (bw.ns6) return document.getElementById(ID);
else if (bw.ns) return document.layers[ID];
else return document.all[ID];
}
function getLayerX( ID ) {
if (bw.ns6) return(parseInt(document.getElementById(ID).style.left));
else if (bw.ns) return(document.layers[ID].left);
else return(document.all[ID].offsetLeft);
}
function getLayerY( ID ) {
if (bw.ns6) return(parseInt(document.getElementById(ID).style.top));
else if (bw.ns) return(document.layers[ID].top);
else return(document.all[ID].offsetTop);
}
function getLayerSW( ID ) {
if (bw.ns6) {
if(isNaN(parseInt(document.getElementById(ID).style.width))) return(parseInt(document.defaultView.getComputedStyle(document.getElementById(ID),null).getPropertyValue('width')));
else if(parseInt(document.getElementById(ID).style.width)==0) return(parseInt(document.defaultView.getComputedStyle(document.getElementById(ID),null).getPropertyValue('width')));
else return(parseInt(document.getElementById(ID).style.width));
}else if (bw.ns) return(document.layers[ID].document.width);
else return(document.all[ID].scrollWidth);
}
function getLayerSH( ID ){
if (bw.ns6) {
if(isNaN(parseInt(document.getElementById(ID).style.height))) return(parseInt(document.defaultView.getComputedStyle(document.getElementById(ID),null).getPropertyValue('height')));
else if(parseInt(document.getElementById(ID).style.height)==0) return(parseInt(document.defaultView.getComputedStyle(document.getElementById(ID),null).getPropertyValue('height')));
else return(parseInt(document.getElementById(ID).style.height));
}else if (bw.ns) return(document.layers[ID].document.height);
else return(document.all[ID].scrollHeight);
}
function getLayerW( ID ) {
if (bw.ns6) return(parseInt(document.getElementById(ID).style.width));
else if (bw.ns) return(document.layers[ID].document.width);
else return(document.all[ID].offsetWidth);
}
function getLayerH( ID ){
if (bw.ns6) return(parseInt(document.getElementById(ID).style.height));
else if (bw.ns) return(document.layers[ID].document.height);
else return(document.all[ID].offsetHeight);
}
解决方案 »
- 求救!!api百度地图,自定义公车面板的用法
- 请教一个传值切换问题
- 更换鼠标效果
- 求救:return false 不起作用
- 20分求一个javascript取值问题,解决就结贴
- 怎样用JS控制服务器控件listbox
- <input type=file>.value是readonly的, 如何赋值?
- 如何设置不同域的cookie即第三方cookie?
- 点击连接,强制下载,html也不例外,怎么实现??
- 请教各位高手,学习JavaScipt应看什么书入门上手?
- 页面搜索是怎么做了?http://www.ylstudy.net/article/article.asp
- 用javascript向word里传值?(真诚等待高手帮助和制导)急!急!急!
function getVisibility( ID ) {
if (bw.ns6) return(document.getElementById(ID).style.visibility!="hidden");
else if (bw.ns) return(document.layers[ID].visibility!="hide");
else return(document.all[ID].style.visibility!="hidden"&&document.all[ID].style.visibility!="HIDDEN");
}
function getZIndex( ID ) {
if (bw.ns6) return(document.getElementById(ID).style.zIndex);
else if (bw.ns) return(document.layers[ID].zIndex);
else return(document.all[ID].style.zIndex);
}
function changeZIndex( ID, z ) {
if (bw.ns6) document.getElementById(ID).style.zIndex = z;
else if (bw.ns) document.layers[ID].zIndex = z;
else document.all[ID].style.zIndex = z;
}
function showLayer( ID ) {
if (bw.ns6) {
document.getElementById(ID).style.visibility = "visible";
document.getElementById(ID).style.pixelHeight = getLayerSH(ID);
}else if (bw.ns) {
document.layers[ID].visibility = "show";
document.layers[ID].clip.height = getLayerSH(ID);
}else {
document.all[ID].style.visibility = "visible";
document.all[ID].style.pixelHeight = getLayerSH(ID);
}
}
function hideLayer( ID ) {
if (bw.ns6) {
document.getElementById(ID).style.visibility = "hidden";
document.getElementById(ID).style.pixelHeight = 0;
}else if (bw.ns) {
document.layers[ID].visibility = "hide";
document.layers[ID].clip.height = 0;
}else {
document.all[ID].style.visibility = "hidden";
document.all[ID].style.pixelHeight =0;
}
}
function loadImg() {
if (document.images) {
var imgStr = loadImg.arguments;
if (!document.preloadArray) document.preloadArray = new Array();
var n = document.preloadArray.length;
for (var i=0; i<loadImg.arguments.length; i++) {
document.preloadArray[n] = new Image;
document.preloadArray[n].src = imgStr[i];n++;
}
}
}
function makeImgSrc(imgSRC,imgID) {
if (bw.ns4 && makeImgSrc.arguments.length > 2) {
var thisDocument = '';
for (var i=(makeImgSrc.arguments.length-1) ; i>=2 ; i--) {
thisDocument += 'document.layers["'+makeImgSrc.arguments[i]+'"].';
}
thisDocument += 'document.images["'+imgID+'"].src="'+imgSRC+'"';
eval(thisDocument);
}else document.images[imgID].src = imgSRC;
}
function changeContent( ID, str) {
if (bw.ns4) {
document.layers[ID].document.open();
document.layers[ID].document.write(str);
document.layers[ID].document.close();
}else if(bw.ns6) {
if(bw.mac) str += "<br>";document.getElementById(ID).innerHTML = str;
}else if(bw.ie) {
if(bw.mac) str += "<br>";document.all[ID].innerHTML = str;
}
}
function clipTo( ID, x, y, w, h) {
if (bw.ns4) {
document.layers[ID].clip.left = x;
document.layers[ID].clip.top = y;
document.layers[ID].clip.width = w;
document.layers[ID].clip.height = h;
}else{
if(bw.ns6) the_elt = document.getElementById(ID);
else if(bw.ie) the_elt = document.all[ID];
var the_clip = "rect("+y+"px "+w+"px "+h+"px "+x+"px)";
the_elt.style.clip = the_clip;the_elt.style.overflow = "hidden";
}
}
function setBgColor( ID, C ) {
if (bw.ns4) {
document.layers[ID].bgColor = C;
}else if(bw.ns6) {
document.getElementById(ID).style.backgroundColor = C;
}else if(bw.ie) {
document.all[ID].style.backgroundColor = C;
}
}
注意var bw = new lib_bwcheck();石必需的,因为考虑到适应更多浏览器,几乎所有函数中都做了浏览器检查。
下面是动画效果的函数,这个动画具有阻尼特性。
var aoa = new Array();//对象集合
var ANICOUNT = -1;//步数
var ANIMODE = true; //起开关作用,你可以动态改变为false,使其不支持动画移动效果function makeAnimate() {
this.aoa = aoa.length;
aoa[aoa.length] = this;
this.animating = false;
this.StartX = 0;
this.StartY = 0;
this.EndX = 0;
this.EndY = 0;
this.EndY = 0;
this.aniSpeed =18;//移动速度
this.timeOut = null;
this.aniExe = "";
this.startAni = startAni;
this.ani = checkAni;
}function startAni( endx, endy, aniSpeed) {
if(ANIMODE) {
this.animating = true;
this.StartX = this.x;
this.StartY = this.y;
this.EndX = endx;
this.EndY = endy;
this.aniSpeed = (aniSpeed!=null) ? aniSpeed : this.aniSpeed;
if(this.timeOut != null) {
clearTimeout(this.timeOut);
ANICOUNT--;
}
ANICOUNT++;
this.ani();
}else {
this.EndX = endx;
this.EndY = endy;
this.moveToXY(endx, endy);
}
}
function checkAni() {
if (this.EndX > this.StartX) {
this.x += Math.floor((this.EndX - this.x) / this.aniSpeed) + 1;
if (this.x > this.EndX) this.x = this.EndX;
}else {
this.x += Math.floor((this.EndX - this.x) / this.aniSpeed) - 1;
if (this.x < this.EndX) this.x = this.EndX;
}
if (this.EndY > this.StartY) {
this.y += Math.floor((this.EndY - this.y) / this.aniSpeed) + 1;
if (this.y > this.EndY) this.y = this.EndY;
}else {
this.y += Math.floor((this.EndY - this.y) / this.aniSpeed) - 1;
if (this.y < this.EndY) this.y = this.EndY;
}
this.moveTo(this.x,this.y);
if (this.x != this.EndX || this.y != this.EndY ) {
this.timeOut = eval("setTimeout('aoa[" + this.aoa + "].ani()',10)");
}else {
clearTimeout(this.timeOut);
this.timeOut = null;
this.animating = false;
ANICOUNT--;
if(this.aniExe){
eval(this.aniExe);
this.aniExe = "";
}
}
}
我正在整理中,继续贴出我的收藏
do you want to it?
<!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的。