87,921
社区成员
发帖
与我相关
我的任务
分享
function getScreenSize(target)
{
var theWidth,theHeight;
if (target.innerWidth)
{
theWidth = target.innerWidth
theHeight = target.innerHeight
}
else if (target.document.compatMode=='CSS1Compat')
{
theWidth = target.document.documentElement.clientWidth
theHeight = target.document.documentElement.clientHeight
}
else if (target.document.body)
{
theWidth = target.document.body.clientWidth
theHeight = target.document.body.clientHeight
}
var result = [theWidth,theHeight];
return result;
}
var width = getScreenSize(window)[0];
var height=getScreenSize(window)[1];
alert("宽:"+width+",高:"+height);