获取非行间样式因为存在兼容问题 有两种方式:非ie浏览器和IE8及以下
非行间样式获取的是除css行内式以外的内嵌式和外联式内容
非IE获取方法
// attr ==>要获取的元素
// ele ==>要获取的元素的样式
window.getComputedStyle(attr).ele
IE8及以下获取方法
(attr).currentStyle.ele
使用
if(getComputedStyle){
window.getComputedStyle(attr).ele
}else{
(attr).currenStyle.ele
}
=================================================================
window.getComputedStyle ?window.getComputedStyle(attr).ele:(attr).currenStyle.ele
获取行间样式内容
attr.style.ele
给元素添加样式的值
只能给行内式和js添加的样式添加值
attr.style.ele="100px" 或者 其他值
获取浏览器的宽高
window.innerHeight
window.Width