JS大总结.docx

上传人:b****6 文档编号:7118605 上传时间:2023-01-19 格式:DOCX 页数:66 大小:74.80KB
下载 相关 举报
JS大总结.docx_第1页
第1页 / 共66页
JS大总结.docx_第2页
第2页 / 共66页
JS大总结.docx_第3页
第3页 / 共66页
JS大总结.docx_第4页
第4页 / 共66页
JS大总结.docx_第5页
第5页 / 共66页
点击查看更多>>
下载资源
资源描述

JS大总结.docx

《JS大总结.docx》由会员分享,可在线阅读,更多相关《JS大总结.docx(66页珍藏版)》请在冰豆网上搜索。

JS大总结.docx

JS大总结大总结javascript事件查询综合click()对象.click()使对象被点击。

closed对象.closed对象窗口是否已关闭true/falseclearTimeout(对象)清除已设置的setTimeout对象clearInterval(对象)清除已设置的setInterval对象confirm(提示信息)弹出确认框,确定返回true取消返回falsecursor:

样式更改鼠标样式handcrosshairtextwaithelpdefaultautoe/s/w/n-resizeevent.clientX返回最后一次点击鼠标X坐标值;event.clientY返回最后一次点击鼠标Y坐标值;event.offsetX返回当前鼠标悬停X坐标值event.offsetY返回当前鼠标悬停Y坐标值document.write(document.lastModified)网页最后一次更新时间document.ondblclick=x当双击鼠标产生事件document.onmousedown=x单击鼠标键产生事件document.body.scrollTop;返回和设置当前竖向滚动条的坐标值,须与函数配合,document.body.scrollLeft;返回和设置当前横向滚动务的坐标值,须与函数配合,document.titledocument.title=message;当前窗口的标题栏文字document.bgcolordocument.bgcolor=颜色值;改变窗口背景颜色document.Fgcolordocument.Fgcolor=颜色值;改变正文颜色document.linkcolordocument.linkcolor=颜色值;改变超联接颜色document.alinkcolordocument.alinkcolor=颜色值;改变正点击联接的颜色document.VlinkColordocument.VlinkColor=颜色值;改变已访问联接的颜色document.forms.length返回当前页form表单数document.anchors.length返回当前页锚的数量document.links.length返回当前页联接的数量document.onmousedown=x单击鼠标触发事件document.ondblclick=x双击鼠标触发事件defaultStatuswindow.status=defaultStatus;将状态栏设置默认显示functionfunctionxx().定义函数isNumeric判断是否是数字innerHTMLxx=对象.innerHTML输入某对象标签中的html源代码innerTextdivid.innerText=xx将以div定位以id命名的对象值设为XXlocation.reload();使本页刷新,target可等于一个刷新的网页Math.random()随机涵数,只能是0到1之间的数,如果要得到其它数,可以为*10,再取整Math.floor(number)将对象number转为整数,舍取所有小数Math.min(1,2)返回1,2哪个小Math.max(1,2)返回1,2哪个大navigator.appName返回当前浏览器名称navigator.appVersion返回当前浏览器版本号navigator.appCodeName返回当前浏览器代码名字navigator.userAgent返回当前浏览器用户代标志onsubmitonsubmit=return(xx()使用函数返回值openeropener.document.对象控制原打开窗体对象promptxx=window.prompt(提示信息,预定值);输入语句parentparent.框架名.对象控制框架页面returnreturnfalse返回值random随机参数(0至1之间)reset()form.reset();使form表单内的数据重置split()string.split()将string对象字符以逗号隔开submit()form对象.submit()使form对象提交数据String对象的charAt(x)对象反回指定对象的第多少位的字母lastIndexOf(string)从右到左询找指定字符,没有返回-1indexOf(string)从左到右询找指定字符,没有返回-1LowerCase()将对象全部转为小写UpperCase()将对象全部转为大写substring(0,5)string.substring(x,x)返回对象中从0到5的字符setTimeout(function,time)设置一个超时对象setInterval(function,time)设置一个超时对象toLocaleString()x.toLocaleString()从x时间对象中获取时间,以字符串型式存在typeof(变量名)检查变量的类型,值有:

String,Boolean,Object,Function,Underfinedwindow.event.button=1/2/3鼠标键左键等于1右键等于2两个键一起按为3window.screen.availWidth返回当前屏幕宽度(空白空间)window.screen.availHeight返回当前屏幕高度(空白空间)window.screen.width返回当前屏幕宽度(分辨率值)window.screen.height返回当前屏幕高度(分辨率值)window.document.body.offsetHeight;返回当前网页高度window.document.body.offsetWidth;返回当前网页宽度window.resizeTo(0,0)将窗口设置宽高window.moveTo(0,0)将窗口移到某位置window.focus()使当前窗口获得焦点window.scroll(x,y)窗口滚动条坐标,y控制上下移动,须与函数配合window.open()window.open(地址,名称,属性)属性:

toolbar(工具栏),location(地址栏),directions,status(状态栏),menubar(菜单栏),scrollbar(滚动条),resizable(改变大小),width(宽),height(高),fullscreen(全屏),scrollbars(全屏时无滚动条无参数,channelmode(宽屏),left(打开窗口x坐标),top(打开窗口y坐标)window.location=view-source:

+window.location.href应用事件查看网页源代码;a=newDate();/创建a为一个新的时期对象y=a.getYear();/y的值为从对象a中获取年份值两位数年份y1=a.getFullYear();/获取全年份数四位数年份m=a.getMonth();/获取月份值d=a.getDate();/获取日期值d1=a.getDay();/获取当前星期值h=a.getHours();/获取当前小时数m1=a.getMinutes();/获取当前分钟数s=a.getSeconds();/获取当前秒钟数对象.style.fontSize=文字大小;单位:

mm/cm/in英寸/pc帕/pt点/px象素/em文字高1in=1.25cm1pc=12pt1pt=1.2px(800*600分辩率下)文本字体属性:

fontSize大小family字体color颜色fontStyle风格,取值为normal一般,italic斜体,oblique斜体且加粗fontWeight加粗,取值为100到900不等,900最粗,light,normal,boldletterSpacing间距,更改文字间距离,取值为,1pt,10px,1cmtextDecoration:

文字修饰;取值,none不修饰,underline下划线,overline上划线background:

文字背景颜色,backgroundImage:

背景图片,取值为图片的插入路径点击网页正文函数调用触发器:

1.onClick当对象被点击2.onLoad当网页打开,只能书写在body中3.onUnload当网页关闭或离开时,只能书写在body中4.onmouseover当鼠标悬于其上时5.onmouseout当鼠标离开对象时6.onmouseup当鼠标松开7.onmousedown当鼠标按下键8.onFocus当对象获取焦点时9.onSelect当对象的文本被选中时10.onChange当对象的内容被改变11.onBlur当对象失去焦点onsubmit=return(ss()表单调用时返回的值直线border-bottom:

1xsolidblack虚线border-bottom:

1xdottedblack点划线border-bottom:

2xdashedblack双线border-bottom:

5xdoubleblack槽状border-bottom:

1xgrooveblack脊状border-bottom:

1xridgeblack1.边缘高光glow(color=颜色,strength=亮光大小)2.水平翻转fliph()使对象水平翻转180度3.垂直翻转flipv()使对象垂直翻转180度4.对象模糊blur(add=true/falsedirection=方向strength=强度)add指定是否按印象画派进行模糊direction模糊方向strength模糊强度5.对象透明alpha(opaction=0-100,finishopacity=0-100,style=0/1/2/3)opaction对象整体不透明值finishopacity当对象利用了渐透明时该项指定结束透明位置的不透明值style指定透明方式0为整体透明,1为线型透明,2为圆型透明,3为矩形透明6.去除颜色chroma(color=颜色值)使对象中颜色与指定颜色相同区域透明7.建立阴影dropshadow(color=阴影颜色,offx=水平向左偏离像素,offy=水平向下偏离像素)8.去色gray()使对象呈灰度显示9.负片效果invert()使对象呈底片效果10.高光light()使对象呈黑色显示11.遮盖mask(color=颜色)使整个对象以指定颜色进行蒙板一次opacity表透明度水平.0100,0表全透明,100表完全不透明finishopacity表想要设置的渐变透明效果.0100.style表透明区的形状.0表统一形状.1表线形.2表放射形.3表长方形.startx.starty表渐变透明效果的开始时X和Y坐标.finishx,finishy渐变透明效果结束时x,y的坐标.add有来确定是否在模糊效果中使有原有目标.值为0,1.0表否,1表是.direction设置模糊的方向.0度表垂直向上,45度为一个单位.默认值是向左270度.left,right,down,up.strength只能用整数来确定.代表有多少个像素的宽度将受到模糊影响.默认是5个.color要透明的颜色.offx,offy分别是x,y方向阴影的偏移量.positive指投影方式.0表透明像素生成阴影.1表只给出不透明像素生成阴影.AddAmbient:

加入包围的光源.AddCone:

加入锥形光源.AddPoint加入点光源Changcolor:

改变光的颜色Changstrength:

改变光源的强度Clear:

清除所有的光源MoveLight:

移动光源freq是波纹的频率,在指定在对象上一区需要产生多少个完事的波纹lightstrength可对于波纹增强光影的效果显著0100正整数,正弦波开始位置是0360度0表从0度开始,25表从90度开始strength表振幅大小handstyle=cursor:

handcrosshairstyle=cursor:

crosshairtextstyle=cursor:

textwaitstyle=cursor:

waitdefaultstyle=cursor:

defaulthelpstyle=cursor:

helpe-resizestyle=cursor:

e-resizene-resizestyle=cursor:

ne-resizen-resizestyle=cursor:

n-resizenw-resizestyle=cursor:

nw-resizew-resizestyle=cursor:

w-resizes-resizestyle=cursor:

s-resizesw-resizestyle=cursor:

sw-resizese-resizestyle=cursor:

se-resizeautostyle=cursor:

auto数字输入控制,给数字加上千分符.inputRighttext-align:

right;border:

1px#666666dashed;font-size:

9pt;color:

#993366;height:

18px;ime-mode:

disabled;/*这些功能建议通过HTC来实现*/数字输入控制functionFormatInput(dotlen)varmyEle=event.srcElement;varmyValue=String.fromCharCode(event.keyCode);if(myEle.readOnly)return;switch(dotlen)/原正则表达式(可以输入负数):

/-?

d*.?

d0,0$/case0:

event.returnValue=regInput(myEle,/d*.?

d0,0$/,myValue);break;case1:

event.returnValue=regInput(myEle,/d*.?

d0,1$/,myValue);break;case2:

event.returnValue=regInput(myEle,/d*.?

d0,2$/,myValue);break;case3:

event.returnValue=regInput(myEle,/d*.?

d0,3$/,myValue);break;case4:

event.returnValue=regInput(myEle,/d*.?

d0,4$/,myValue);break;case5:

event.returnValue=regInput(myEle,/d*.?

d0,5$/,myValue);break;case6:

event.returnValue=regInput(myEle,/d*.?

d0,6$/,myValue);break;case7:

event.returnValue=regInput(myEle,/d*.?

d0,7$/,myValue);break;case8:

event.returnValue=regInput(myEle,/d*.?

d0,8$/,myValue);break;default:

event.returnValue=regInput(myEle,/d*.?

d0,0$/,myValue);break;functionregInput(obj,reg,inputStr)vardocSel=document.selection.createRange()if(docSel.parentElement().tagName!

=INPUT)returnfalseoSel=docSel.duplicate()oSel.text=varsrcRange=obj.createTextRange()oSel.setEndPoint(StartToStart,srcRange)varstr=oSel.text+inputStr+srcRange.text.substr(oSel.text.length)returnreg.test(str)/给数字加上千分符byyuanzyfunctionsplitNumber(eValue)varintPart=;vardecPart=;if(eValue.indexOf(,)=0)eValue=eValue.replace(/,/g,);if(eValue.indexOf(.)=0)intPart=eValue.split(.)0;decPart=eValue.split(.)1;elseintPart=eValue;varnum=intPart+;varre=/(-?

d+)(d3)/while(re.test(num)num=num.replace(re,$1,$2)if(eValue.indexOf(.)=0)eValue=num+.+decPart;elseeValue=num;returneValue;functionoFocus()if(event.srcElement.readOnly)return;event.srcElement.value=event.srcElement.value.replace(/,/g,);functionoBlur()if(event.srcElement.value=-)event.srcElement.value=;event.srcElement.value=splitNumber(event.srcElement.value);IE功能汇总窗口打开自动最大化代码if(window.screenLeft!

=0)max.Click();利用脚本封装,方便实现网站悬浮广告下面是JS脚本(floatdiv.js)/*=浮动块支持脚本DESIGNBY:

彭国辉DATE:

2004-02-26SITE:

http:

/EMAIL:

搜索更多相关主题的帖子:

javascriptfalsehelp2006-10-1616:

41:

03islet等级:

贵宾威望:

89帖子:

6552专家分:

0注册:

2005-1-28第2楼得分:

0文章为作者原创,转载前请先与本人联系,转载请注明文章出处、保留作者信息,谢谢支持!

=*/varalLeft=0,alCenter=1,alRight=2;/水平对齐方式varalTop=0,alMiddle=1,alBottom=2;/垂直对齐方式varf=newArray();varcnt=0;functionfloatDiv(objId,align,vAlign,x,y,smooth)/*浮动块对象数据结构:

objId:

对象IDalign:

水平对齐方式,枚举型vAlign:

垂直对齐方式,枚举型内容x,y:

xy座标,整型smooth:

平滑移动,布尔型*/this.objId=objId;this.align=align;this.vAlign=vAlign;this.x=x;this.y=y;this.smooth=smooth;functionaddDiv(objId,align,vAlign,x,y,smooth)/添加浮动块fcnt+=newfloatDiv(objId,align,vAlign,x,y,smooth);functionfloatMove()/重新定位各块位置varobjX,objY;if(document.all)vard=document.body;/status=scrollLeft:

+f0.objId.style.pixelTop+|offsetWidth:

+d.offsetWidth;for(vari=0;if.length;i+)switch(fi.align)casealLeft:

objX=d.scrollLeft+fi.x;break;casealCenter:

objX=d.scrollLeft+Math.ceil(d.offsetWidth-fi.objId.offsetWidth)/2)+fi.x;break;casealRight:

objX=d.scrollLeft+d.offsetWidth-fi.x-fi.objId.offsetWidth-20;break;/减滚动条20switch(fi.vAlign)casealTop:

objY=d.scrollTop+fi.y;break;casealMiddle:

objY=d.scrollTop+Math.ceil(d.offsetHeight-fi.objId.offsetHeight)/2)+fi.y;break;casealBottom:

objY=d.scrollTop+d.offsetHeight-fi.y-fi.objId.offsetHeight;break;if(fi.smooth)smoothMove(fi.objId,objX,objY);elsefi.objId.style.pixelLeft=objX;fi.objId.style.pixelTop=objY;if(document.layers)for(vari=0;i0)percent=Math.ceil(percent);elsepercent=Math.floor(percent);obj.style.pixelLeft+=percent;percent=.1*(y-obj.style.pixelTop);if(percent0)percent=Math.ceil(percent);elsepercent=Math.floor(percent);obj.style.pixelTop+=percent;if(document.layers)percent=.1*(x-document.objId.left);if(percent0)percent=Math.ceil(percent);elsepercent=Math.floor(percent);document.objId.left+=percent;percent=.1*(y-document.objId.top);if(percent0)percent=Math.ceil(percent);elsepercent=Math.floor(percent);document.objId.top+=percent;setTimeout(floatMove();,50);调用例子:

if(navigator.appName=Netscape)document.write();elsedocument.write();addDiv(ad_hr,alRight,alTop,0,30,true);原创自己定义的简单方法验证表单数据方法很简单,先是定义好要验证的数组比如:

check_array0=newArray(title,留言主题不能为空!

);然后判断,错误的就提示定义的内容,代码如下:

/表单验证程序;/定义获取表单元素;function$()varelements=newArray();for(vari=0;i

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 工作范文 > 行政公文

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1