鼠标事件
onclick
ondblclick
onmouseenter
onmouseleave
onmousemove
event.clientX;
event.clientY;
键盘事件
onkeydown
event.keyCode;
event.value;
onkeyup
onkeypress
获取窗口的宽高
document.documentElement.clientHeight;
document.documentElement.clientWidth;
获取屏幕的高度
document.documentElement.scrollHeight;
document.documentElement.scrollWidht;
滚动的高度
document.documentElement.scrollTop;
document.body.scrollTop(chrome)
表单事件
onfocus 获得焦点
onblur 失去焦点
onchange 内容改变
onselect 被选中
onsubmit 提交时
onreset 重置时
placeholder='';占位:灰色的显示内容,获得焦点后就清空已有的内容
其他事件
window.onlaad=function(){}
onerror
onresize
onscroll滚动条
点击返回顶部即可返回顶部
topobj=document.getElementById('top');
topobj.onclick=function(){
nu=navigator.userAgent;
if(nu.match(/chrome/i)){
//谷歌
document.body.scrollTop=0;
}else{
//非谷歌
document.documentElement.scrollTop=0;
}
}
表单方法
BOM(browser object model 浏览器对象模型)
window对象
属性:
frames 窗口数组
opener 打开我的那个数组
top 顶级窗口
方法:
alert()
confirm()
prompt()
setInterval()
clearInterval()
setTimeout()
clearTimeout()
navigator浏览器特性
userAgent 获取浏览器属性
screen屏幕对象(根据屏幕分辨率的大小改变样式)
height
width
availHeight
availwidth
history对象
back()后退一个历史
forward()前进一个历史
go(-1)后退一个历史
locztion地址栏
属性:
hash 获取url里的锚点#abc
host 主机名
href 当前的url地址
pathname index.html页面的名称
protocol 协议 http://
search 参数 ?id=10
方法:
reload();
document对象
document
document.documentElement
document.head
document.title
document.body
document元素对象方法
document.getElementById()
docuemnt.getElementByTagName()
document.getElementsByClassName()
document.getElementByName()
元素对象标准属性
obj.id
obj.className
obj.style
obj.title
action
methoe
元素非标准属性
getAttribute('age');
setAttribute('age','50');
元素对象js属性
obj.tagName; 标签的名字
obj.innerHTML; 标签的内容
obj.outerHTML; 标签的全部内容
obj.textContent; 只获取文本内容过滤标签
js学习笔记(二)
最新推荐文章于 2024-03-08 23:01:16 发布