简单的一个js ,希望对大家有帮助
ourl :为要浏览的图片url
<script language="JavaScript">
function openautosize(ourl) {
dimg = new Image();
dimg.src = ourl;
w = dimg.width ;
h = dimg.height + 28;
x = (screen.width - w) / 2;
y = (screen.height - h) / 2;
window.open("win.aspx","","Scrollbars=no,Toolbar=no,Location=no,Direction=no,Resizeable=no,width=" + w + ",Height=" + h + ",top=220,left=280");
// window.open(ourl,"newwindow","location=1,width="+w+",height="+h+",top="+y+",bottom="+y+",left="+x+",right="+x) ;
}
</script>
function openautosize(ourl) {
dimg = new Image();
dimg.src = ourl;
w = dimg.width ;
h = dimg.height + 28;
x = (screen.width - w) / 2;
y = (screen.height - h) / 2;
window.open("win.aspx","","Scrollbars=no,Toolbar=no,Location=no,Direction=no,Resizeable=no,width=" + w + ",Height=" + h + ",top=220,left=280");
// window.open(ourl,"newwindow","location=1,width="+w+",height="+h+",top="+y+",bottom="+y+",left="+x+",right="+x) ;
}
</script>
转载于:https://blog.51cto.com/smilecong/196297