标题BOOM类封装函数
1.// 封装兼容性方法,可视区窗口大小
function getViewportOffset(){
if(window.innerHeight){
return{
w:window.innerWidth,
h:window.innerHeight
}
}else{
if(document.compatMode===‘BackCompat’){
return{
w:document.body.clientWidth,
h:document.body.clientHeight
}
}else{
return{
w:document.documentElement.clientWidth,
h:document.documentElement.clientHeight
}
}
}
}
2.//div.getBoundingClientRect();查看div的一切信息
3.// 封装获取不同浏览器下样式值
function getStyle(elem,prop){
if(window.getComputedStyle){
return window.getComputedStyle(elem,null)[prop]//主流浏览器
}else{
return elem.currentStyle[prop]//ie9以下
}
}
// 调用方法:getStyle(元素名,‘属性名’)
4.// 改变伪元素值
div.οnclick=function(){
div.className=‘red’;
}//通过改变元素名改变值,相当于引入另一个样式