Extjs 的messagebox 显示 问题
我显示messagebox 的时候 总是按钮先出现在右边 然后 移动到左边 有个移动的过程 
官方的例子 如果是静态HTML 是没这个问题的  放在服务器上改为jsp的 也会这样
求解
用的是EXTjs 3.0.3

解决方案 »

  1.   

    不是msg的问题,是你的代码写得有问题。有没有重复的id、或是css引入了没
    单凭左移有问题,可能很的代码冲突有关
    Ext.Msg.confirm 参数传递是否匹配
      

  2.   

    <%@ page language="java" contentType="text/html; charset=UTF-8"%>
    <%@ taglib prefix="s" uri="/struts-tags"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head> 
    <meta http-equiv="pragma"content="no-cache"> 
    <meta http-equiv="cache-control"content="no-cache,must-revalidate"> 
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link rel="stylesheet" type="text/css" href="../../extjs/resources/css/ext-all.css" />
      <script type="text/javascript" src="../../extjs/adapter/ext/ext-base.js"></script>
        <script type="text/javascript" src="../../extjs/ext-all.js"></script>      
        
    <title>test</title>
        <link rel="stylesheet" type="text/css" href="../../extjs/examples/shared/examples.css"/>
    <script type="text/javascript">
    /*!
     * Ext JS Library 3.0.3
     * Copyright(c) 2006-2009 Ext JS, LLC
     * [email protected]
     * http://www.extjs.com/license
     */
    Ext.onReady(function(){
        Ext.get('mb1').on('click', function(e){
            Ext.MessageBox.confirm('Confirm', 'Are you sure you want to do that?', showResult);
        });    Ext.get('mb2').on('click', function(e){
            Ext.MessageBox.prompt('Name', 'Please enter your name:', showResultText);
        });    Ext.get('mb3').on('click', function(e){
            Ext.MessageBox.show({
               title: 'Address',
               msg: 'Please enter your address:',
               width:300,
               buttons: Ext.MessageBox.OKCANCEL,
               multiline: true,
               fn: showResultText,
               animEl: 'mb3'
           });
        });    Ext.get('mb4').on('click', function(e){
            Ext.MessageBox.show({
               title:'Save Changes?',
               msg: 'You are closing a tab that has unsaved changes. <br />Would you like to save your changes?',
               buttons: Ext.MessageBox.YESNOCANCEL,
               fn: showResult,
               animEl: 'mb4',
               icon: Ext.MessageBox.QUESTION
           });
        });    Ext.get('mb6').on('click', function(){
            Ext.MessageBox.show({
               title: 'Please wait',
               msg: 'Loading items...',
               progressText: 'Initializing...',
               width:300,
               progress:true,
               closable:false,
               animEl: 'mb6'
           });       // this hideous block creates the bogus progress
           var f = function(v){
                return function(){
                    if(v == 12){
                        Ext.MessageBox.hide();
                        Ext.example.msg('Done', 'Your fake items were loaded!');
                    }else{
                        var i = v/11;
                        Ext.MessageBox.updateProgress(i, Math.round(100*i)+'% completed');
                    }
               };
           };
           for(var i = 1; i < 13; i++){
               setTimeout(f(i), i*500);
           }
        });    Ext.get('mb7').on('click', function(){
            Ext.MessageBox.show({
               msg: 'Saving your data, please wait...',
               progressText: 'Saving...',
               width:300,
               wait:true,
               waitConfig: {interval:200},
               icon:'ext-mb-download', //custom class in msg-box.html
               animEl: 'mb7'
           });
            setTimeout(function(){
                //This simulates a long-running operation like a database save or XHR call.
                //In real code, this would be in a callback function.
                Ext.MessageBox.hide();
                Ext.example.msg('Done', 'Your fake data was saved!');
            }, 8000);
        });    Ext.get('mb8').on('click', function(){
            Ext.MessageBox.alert('Status', 'Changes saved successfully.', showResult);
        });    //Add these values dynamically so they aren't hard-coded in the html
        Ext.fly('info').dom.value = Ext.MessageBox.INFO;
        Ext.fly('question').dom.value = Ext.MessageBox.QUESTION;
        Ext.fly('warning').dom.value = Ext.MessageBox.WARNING;
        Ext.fly('error').dom.value = Ext.MessageBox.ERROR;    Ext.get('mb9').on('click', function(){
            Ext.MessageBox.show({
               title: 'Icon Support',
               msg: 'Here is a message with an icon!',
               buttons: Ext.MessageBox.OK,
               animEl: 'mb9',
               fn: showResult,
               icon: Ext.get('icons').dom.value
           });
        });    function showResult(btn){
            Ext.example.msg('Button Click', 'You clicked the {0} button', btn);
        };    function showResultText(btn, text){
            Ext.example.msg('Button Click', 'You clicked the {0} button and entered the text "{1}".', btn, text);
        };
    });
    </script>   
    </head>
    <body>
     <script type="text/javascript" src="../../extjs/examples/shared/examples.js"></script>
    <h1>MessageBox Dialogs</h1>
    <p>The example shows how to use the MessageBox class. Some of the buttons have animations, some are normal.</p>
    <p>The js is not minified so it is readable. See <a href="msg-box.js">msg-box.js</a>.</p><p>
        <b>Confirm</b><br />
        Standard Yes/No dialog.
        <button id="mb1">Show</button>
    </p><p>
        <b>Prompt</b><br />
        Standard prompt dialog.
        <button id="mb2">Show</button>
    </p><p>
        <b>Multi-line Prompt</b><br />
        A multi-line prompt dialog.
        <button id="mb3">Show</button>
    </p><p>
        <b>Yes/No/Cancel</b><br />
        Standard Yes/No/Cancel dialog.
        <button id="mb4">Show</button>
    </p><p>
        <b>Progress Dialog</b><br />
        Dialog with measured progress bar.
        <button id="mb6">Show</button>
    </p><p>
        <b>Wait Dialog</b><br />
        Dialog with indefinite progress bar and custom icon (will close after 8 sec).
        <button id="mb7">Show</button>
    </p><p>
        <b>Alert</b><br />
        Standard alert message dialog.
        <button id="mb8">Show</button>
    </p><p>
        <b>Icons</b><br />
        Standard alert with optional icon.
        <select id="icons">
            <option id="error" selected="selected">Error</option>
            <option id="info">Informational</option>
            <option id="question">Question</option>
            <option id="warning">Warning</option>
        </select>
        <button id="mb9">Show</button>
    </p>
    </body>
    </html>