日期:2014-05-16  浏览次数:20415 次

前台是个什么东西---JavaScript语法集锦

click()?? 对象.click()?? 使对象被点击。
closed?? 对象.closed?? 对象窗口是否已关闭true/false
clearTimeout(对象) 清除已设置的setTimeout对象
clearInterval(对象) 清除已设置的setInterval对象
confirm("提示信息") 弹出确认框,确定返回true取消返回false
cursor:样式 更改鼠标样式 hand crosshair text wait help default auto e/s/w/n-resize

event.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.title document.title="message"; 当前窗口的标题栏文字
document.bgcolor document.bgcolor="颜色值"; 改变窗口背景颜色
document.Fgcolor document.Fgcolor="颜色值"; 改变正文颜色
document.linkcolor document.linkcolor="颜色值"; 改变超联接颜色
document.alinkcolor document.alinkcolor="颜色值"; 改变正点击联接的颜色
document.VlinkColor document.VlinkColor="颜色值"; 改变已访问联接的颜色
document.forms.length 返回当前页form表单数
document.anchors.length 返回当前页锚的数量
document.links.length 返回当前页联接的数量
document.onmousedown=x 单击鼠标触发事件
document.ondblclick=x 双击鼠标触发事件
defaultStatus window.status=defaultStatus; 将状态栏设置默认显示

function function xx(){...} 定义函数
isNumeric?????????????? 判断是否是数字
innerHTML xx=对象.innerHTML 输入某对象标签中的html源代码
innerText divid.innerText=xx 将以div定位以id命名的对象值设为XX

location.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 返回当前浏览器用户代标志

onsubmit onsubmit="return(xx())" 使用函数返回值
opener?? opener.document.对象 控制原打开窗体对象

prompt?? xx=window.prompt("提示信息","预定值"); 输入语句
parent?? parent.框架名.对象 控制框架页面

return?? return false?? 返回值
random?? 随机参数(0至1之间)
reset()?? form.reset();?? 使form表单内的数据重置

split("") string.split("") 将string对象字符以逗号隔开
submit() form对象.submit() 使form对象提交数据

String对象的 charAt(x)对象 反回指定对象的第多少位的字母
?????? lastIndexOf("string") 从右到左询找指定字符,没有返回-1
?????? indexOf("string") 从左到右询找指定字符,没有返回-1
?????? LowerCase() 将对象全部转为小写?
?????? UpperCase() 将对象全部转为大写
substring(0,5) string.subs