---
title: "将Ext的showConfirm按钮聚焦到no上"
author: "陈碧滔"
date: "2011-11-26T23:23:40Z"
tags: []
categories: ["Web前端"]
slug: "ext-showconfirm-no"
draft: false
lastmod: "2011-11-26T23:23:40Z"
id: 1279119
url: "https://cbt.iteye.com/blog/1279119"
---

在Ext做删除操作时，弹出提示问是否要删除，默认是聚焦在确认按钮上，但是业务上需要将聚焦定位在取消上，防止误删除，用以下方法可以实现。

var dlg = Ext.Msg.confirm('Confirm', 'Do you really want to do this?', fnDoThis).getDialog();  
dlg.defaultButton = 2;  
dlg.focus();

getDialog()获得的是Window。  
dlg下面还有好多方法，和Window下的方法和属性是一样的，因为dlg就是一个Window对象  
所以dlg可以setWidth等等和Window使用方法一样了