---
title: "浏览器窗口大小发生变化时，让弹出的窗体自动居中"
author: "fish_bone"
date: "2011-11-20T17:11:42Z"
tags: ["Extjs4.0", "center()", "onWindowResize", "window"]
categories: ["Web前端"]
slug: "untitled"
draft: false
lastmod: "2011-11-20T17:11:42Z"
id: 1268464
url: "https://fish-bone.iteye.com/blog/1268464"
---

//浏览器窗口大小发生变化时，让弹出的窗体自动居中  
Ext.EventManager.onWindowResize (function(){  
    if(addServerInfoWindow){  
         addServerInfoWindow.setHeight(document.body.clientHeight/1.5);  
        addServerInfoWindow.setWidth(document.body.clientWidth/3);  
        addServerInfoWindow.center();  
    }  
     
    if(updateServerInfoWindow){  
         updateServerInfoWindow.setHeight(document.body.clientHeight/1.5);  
        updateServerInfoWindow.setWidth(document.body.clientWidth/3);  
        updateServerInfoWindow.center();  
    }  
});