document.getElementById('scroll').style.overflowY="scroll"
获取div的高度,如果获取不到,可用下面的方法,一下方法是获取div的编辑完成后的高度:
/**
* obj:需要获取属性的html对象
* prop:需要获取的obj对象的属性
*/
function getCurrentStyle (obj, prop) {
if (obj.currentStyle) {
return obj.currentStyle[prop]
}
else if (window.getComputedStyle) {
propprop = prop.replace (/([A-Z])/g, "-$1")
propprop = prop.toLowerCase ()
return document.defaultView.getComputedStyle (obj,null)[prop]
}
return null
}
var div = document.getElementsByTagName("div")[0]
var height = getCurrentStyle(div,"height")
12
var win_w = $(window).width()//获取宽度
var win_h = $(window).height()//获取高度
如果你想要匹配高度,那么,就是页面刚刚打开其实没有数据,是等页面打开,计算了屏幕高度之后,再根据每条数据的高度计算出条数,再利用ajax的异步传输去读取列表,然后用JS呈现在手机网页中的。