js分辨率问题

来源:百度知道 编辑:UC知道 时间:2024/05/17 08:15:55
function chooseImage(){
var iWidth = window.screen.availWidth;
var iHeight = window.screen.availHeight;

if(iWidth>=1200||iHeight>=1000){
document.body.style.backgroundImage='url("<%=renderResponse.encodeURL(renderRequest.getContextPath()+"/images/spring-birt.jpg")%>")';
document.body.style.marginTop=300;

}else{
document.body.style.backgroundImage='url("<%=renderResponse.encodeURL(renderRequest.getContextPath()+"/images/spring-birt2.jpg")%>")';
document.body.style.marginTop=200;
}
}
这样的一个js文件,我在一个页面index.jsp上加载一次运行正常,然后index.jsp跳转到index2.jsp,我又加载次,index2.jsp网页居然打不开,是怎么回事?js里得代码换成
function chooseImage(){
alert("sss");
}页面index2就可以打开,这是杂回事啊?我要实现的效果就是根据客户IE分辨率呈现不同的背景图片,有什么更好的方法吗?

这里我用这个我以前做的一个打开一个新的页面的代码来做例 子:

function init(){
var tt = window.open('faces/default.jsp','_blank','top=0,left=0,status=no,menubar=no,scrollbars=no,resizable=yes,width='+ screen.width+',height='+screen.height);
if(tt != null){
window.opener = null;
window.close();
}
}

width='+ screen.width+',height='+screen.height);
这2句话就是获得现在本机的分辨率