---
title: "js弹出窗口自适应大小"
author: "hareee"
date: "2011-06-23T13:13:58Z"
tags: []
categories: ["Web前端"]
slug: "js"
draft: false
lastmod: "2011-06-23T13:13:58Z"
id: 1102107
url: "https://hareee.iteye.com/blog/1102107"
---

//弹出窗口高度调整自适应   
  function resetDialogHeight(){  
   if(window.dialogArguments == null){  
    return; //忽略非模态窗口  
   }  
   //正文高度  
   var height = document.body.scrollHeight;  
   //卷进去高度  
   var heightTop = document.body.scrollTop;  
   if (window.XMLHttpRequest) {  
    window.dialogHeight=(height+heightTop+5)+"px";  
   } else {  
    window.dialogHeight=(height+heightTop+55)+"px";//IE6不能自动调整高度，要加45  
   }  
  }  
  window.attachEvent('onload', function(){resetDialogHeight();});