静态MessageBox,代码包含注释,不需要的方法先要注释掉
<html> <head> <title>ExtJs-JSON</title> <link rel="stylesheet" type="text/css" href="resources/css/ext-all.css"> <script type="text/javascript" src="ext-all.js"></script> <script type="text/javascript" src="bootstrap.js"></script> <script type="text/javascript" src="locale/ext-lang-zh-CN.js"></script> <script type="text/javascript"> Ext.onReady(function() { // Ext.MessageBox.alert(title,text,callback); Ext.MessageBox.alert('Alert','Show Alert',callBack); function callBack(id) { Ext.MessageBox.alert('Result','<font color=red>' + id + '</font>'); } }); Ext.onReady(function() { // Ext.MessageBox.prompt(title,text,callback,scope,multilines,defaulttext); Ext.MessageBox.prompt('Prompt','Input some text: ',callBack,this,true,'DefaultValue'); function callBack(id,msg) { Ext.MessageBox.alert('Result','<font color=red>' + id + '</font></Br>' + msg); } }); Ext.onReady(function() { // Ext.MessageBox.confirm(title,text,callback); Ext.MessageBox.confirm('Confirm','Click me!',callBack); function callBack(id,msg) { Ext.MessageBox.alert('Result','<font color=red>' + id + '</font></Br>' + msg); } }); Ext.onReady(function() { // Ext.MessageBox.wait(title,text,properties); Ext.MessageBox.wait('Waiting','Wait!',{text:'Processing!'}); }); Ext.onReady(function(){ // Ext.MessageBox.show(properties); Ext.MessageBox.show({ title:'Tip', msg: 'justwe', modal: true, prompt: true, value: "input", fn: callBack, buttons: Ext.Msg.YESNOCANCEL, icon: Ext.Msg.QUESTION, }); function callBack(id,msg) { Ext.MessageBox.alert('Result','<font color=red>' + id + ' ' + msg'</font>'); } }); </script> </head> <body> </body> </html>
稍微加点动态因素
<html> <head> <title>ExtJs-JSON</title> <link rel="stylesheet" type="text/css" href="resources/css/ext-all.css"> <script type="text/javascript" src="ext-all.js"></script> <script type="text/javascript" src="bootstrap.js"></script> <script type="text/javascript" src="locale/ext-lang-zh-CN.js"></script> <script type="text/javascript"> Ext.onReady(function(){ // update text show time var msgBox = Ext.MessageBox.show({ title:'Tip', msg: 'show time', modal: true, buttons: Ext.Msg.OK, fn: function() { Ext.TaskManager.stop(task); } }) var task = { run:function() { msgBox.updateText('<font color=red>Time: ' + Ext.util.Format.date(new Date(),'Y-m-d g:i:s A</font>')); }, interval:1000 } Ext.TaskManager.start(task); }); Ext.onReady(function() { var msgBox = Ext.MessageBox.show({ title:'Tip', msg: 'show process', modal: true, width:300, progress:true }) var count = 0; var percentage = 0; var progressText = ''; var task = { run: function() { count++; percentage = count/10; progressText = 'Processing: ' + percentage*100 + '%'; msgBox.updateProgress(percentage,progressText,'<font color=red>Now time: ' + Ext.util.Format.date(new Data(),'Y-m-d g:i:s A</font>')); if (count > 10) { Ext.TaskManager.stop(task); msgBox.hide(); } }, interval:1000 } Ext.TaskManager.start(task); }); </script> </head> <body> </body> </html>
来个综合的示例
messagebox_all.html
<html> <head> <title>消息框综合演示</title> <link rel="stylesheet" type="text/css" href="resources/css/ext-all.css"> <script type="text/javascript" src="ext-all.js"></script> <script type="text/javascript" src="bootstrap.js"></script> <script type="text/javascript" src="locale/ext-lang-zh_CN.js"></script> <script type="text/javascript" src="messagebox_all.js"></script> <meta http-equiv="content-type" content="text/html; charset=utf-8"> </head> <body> <h1><font color="red">消息框综合演示</font></h1> <p> <b>Alert</b><br/> 只有OK的确认框 <button id="show_alert">演示</button> </p> <p> <b>Confirm</b><br/> 带有YES||NO的选择框 <button id="show_confirm">演示</button> </p> <p> <b>Prompt</b><br/> 带有文本输入的对话框 <button id="show_prompt">演示</button> </p> <p> <b>Show</b><br/> 自定义对话框 <button id="show_show">演示</button> </p> <p> <b>Progress</b><br/> 带有进度条的对话框(手动) <button id="show_progress">演示</button> </p> <p> <b>Progress_plus</b><br/> 带有进度条的对话框(自动) <button id="show_progress_plus">演示</button> </p> <p> <b>Icon</b><br/> 带有图标的自定义按钮对话框(手动) <button id="show_icon">演示</button> </p> </body> </html>messagebox_all.js