Javascript的使用技巧大全
32.单选按钮组(单选按钮的名称必须相同):取单选按钮组的长度document.forms[0].groupName.length 织梦内容管理系统
33.单选按钮组判定是否被选中也是用checked.
34.下拉列表框的值:document.forms[0].selectName.options[n].value (n有时用下拉列表框名称加上.sel 织梦内容管理系统
ectedIndex来确定被选中的值)
织梦好,好织梦
35.字符串的定义:var myString = new String("This is lightsword"); dedecms.com
36.字符串转成大写:string.toUpperCase(); 字符串转成小写:string.toLowerCase();
37.返回字符串2在字符串1中出现的位置:String1.indexOf("String2")!=-1则说明没找到.
本文来自织梦
38.取字符串中指定位置的一个字符:StringA.charAt(9); copyright dedecms
39.取出字符串中指定起点和终点的子字符串:stringA.substring(2,6); 本文来自织梦
40.数学函数:Math.PI(返回圆周率),Math.SQRT2(返回开方),Math.max(value1,value2)返回两个数中的最
织梦内容管理系统
在值,Math.pow(value1,10)返回value1的十次方,Math.round(value1)四舍五入函数,Math.floor(Math.ra 织梦好,好织梦
ndom()*(n 1))返回随机数 织梦内容管理系统
41.定义日期型变量:var today = new Date();
本文来自织梦
42.日期函数列表:dateObj.getTime()得到时间,dateObj.getYear()得到年份,dateObj.getFullYear()得到
dedecms.com
四位的年份,dateObj.getMonth()得到月份,dateObj.getDate()得到日,dateObj.getDay()得到日期几,dat
eObj.getHours()得到小时,dateObj.getMinutes()得到分,dateObj.getSeconds()得到秒,dateObj.setTi 内容来自dedecms
me(value)设置时间,dateObj.setYear(val)设置年,dateObj.setMonth(val)设置月,dateObj.setDate(va
l)设置日,dateObj.setDay(val)设置星期几,dateObj.setHours设置小时,dateObj.setMinutes(val)设置分,
dateObj.setSeconds(val)设置秒 [注重:此日期时间从0开始计]
43.FRAME的表示方式: [window.]frames[n].ObjFuncVarName,frames["frameName"].ObjFuncVarN 本文来自织梦
ame,frameName.ObjFuncVarName
内容来自dedecms
44.parent代表父亲对象,top代表最顶端对象
45.打开子窗口的父窗口为:opener
46.表示当前所属的位置:this
47.当在超链接中调用JS函数时用:(javascript :)来开头后面加函数名 本文来自织梦
48.在老的浏览器中不执行此JS: 内容来自dedecms
49.引用一个文件式的JS: 织梦好,好织梦
50.指定在不支持脚本的浏览器显示的HTML: copyright dedecms
51.当超链和onCLICK事件都有时,则老版本的浏览器转向a.html,否则转向b.html.例:dfsadf
52.JS的内建对象有:Array,Boolean,Date,Error,EvalError,Function,Math,Number,Object,RangeError, 内容来自dedecms
ReferenceError,RegExp,String,SyntaxError,TypeError,URIError 织梦好,好织梦
53.JS中的换行:

文章评论
共有位Admini5网友发表了评论 查看完整内容