showModalDialog根据内容自动调整窗口大小

来源:互联网 发布:手机淘宝 怎么朋友代付 编辑:程序博客网 时间:2024/04/30 14:27
if( document.body.scrollWidth > (window.screen.availWidth-100) ){
        window.dialogWidth = (window.screen.availWidth-100).toString() + "px"
    }else{
        window.dialogWidth = (document.body.scrollWidth +50).toString() + "px"
    }    
    
    if( document.body.scrollHeight > (window.screen.availHeight-70) ){
        window.dialogHeight = (window.screen.availHeight-50).toString() + "px"
    }else{
        window.dialogHeight = (document.body.scrollHeight +115).toString() + "px"
    }    

    window.dialogLeft = ((window.screen.availWidth - document.body.clientWidth) / 2).toString() + "px"
    window.dialogTop = ((window.screen.availHeight - document.body.clientHeight) / 2).toString() + "px"