Ext 入门的简单messageBox DEMO
<%@ page language="java" pageEncoding="UTF-8"%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><% String path = request.getContextPath(); %><html> <head> <title>My JSP 'ExtHello.jsp' starting page</title><link rel="stylesheet" type="text/css" href="<%=path %>/ext-2.2/resources/css/ext-all.css"><script type="text/javascript" src="<%=path %>/ext-2.2/adapter/ext/ext-base.js"></script><script type="text/javascript" src="<%=path %>/ext-2.2/ext-all.js"></script><script type="text/javascript" src="<%=path %>/ext-2.2/source/locale/ext-lang-zh_CN.js"></script><script type="text/javascript" src="<%=path %>/ExtJsDemo/hello.js"></script> </head> <body> </body></html>
Ext.onReady(function(){//① 小谈 JSON// 定义json对象var jsonObject = {name:'chengYu',age:25,sex:'man',books:[{name:'ThinkInJava',price:107},{name:'Ext之旅',price:59}]};//获取json对象属性//alert(jsonObject.name+" "+jsonObject.age+" "+jsonObject.books[0].name+" "+jsonObject.books[0].price);//遍历json集合/*for(var i=0;i<jsonObject.books.length;i++){alert(jsonObject.books[i].name+" "+jsonObject.books[i].price);}*/Ext.Msg.show(jsonObject);//② 信息提示框 组件基础//Ext.Msg.alert('msgAlertTitle','这种配置很常见');/*Ext.Msg.alert('msgAlertTitle','这种配置很常见',callback);function callback(id){alert(id);}*//*Ext.MessageBox.confirm('删除用户','你确定删除吗?',delCallback);function delCallback(id){if (id=='yes') {alert('删除成功');} else {alert('你选择了no');}}*///------------------------------//Ext.MessageBox 和 Ext.Msg 是相同效果的工具类//Ext.Msg 是 Ext.MessageBox 的别名,只是提供了更简短的调用。//------------------------------//alert('只能使用纯文本');//Ext.MessageBox.alert('<font size=4 color=red>支持html格式文本的div</font>');/*Ext.MessageBox.prompt('备注','请输入评语',promptCallback,this,true);function promptCallback(id,msg){alert('你单击的按钮:'+id+' 输入的内容:'+msg);}*///进度条/*Ext.MessageBox.wait('please wait ...','提示',{text:'进度条上的文字'});*///------------------------------自定义提示框/*var config = { //定义配置对象title:'msgShowTitle',msg:'我的配置很简单,Ext.Msg.show()'};Ext.Msg.show(config);*//*Ext.MessageBox.show({title:'标题',msg:'我有三个按钮、一个多行文本区',modal:true,prompt:true,value:'请输入',fn:showCallback,buttons:Ext.Msg.YESNOCANCEL,icon:Ext.Msg.QUESTION});function showCallback(id,msg){alert(id+" - "+msg);}*///改变默认按钮文本/*Ext.MessageBox.buttonText = {yes:'按钮一',no:'按钮二',cancel:'按钮三'};Ext.MessageBox.show({title:'标题',msg:'我有三个按钮、一个多行文本区',modal:true,prompt:true,value:'请输入',fn:showCallback,buttons:Ext.Msg.YESNOCANCEL,icon:Ext.Msg.QUESTION});function showCallback(id,msg){alert(id+" - "+msg);}*///动态更新文本/*var msgBox = Ext.MessageBox.show({title:'title',msg:'information',modal:true,buttons:Ext.Msg.OK});var task = Ext.TaskMgr.start({run:function(){msgBox.updateText('动态更新'+new Date().format('y-m-d g:i:s a'));},interval:1000});Ext.TaskMgr.start(task);*///progress/*var myBox = Ext.MessageBox.show({title:'title',msg:'information',modal:true,width:300,progress:true});var count = 0; //滚动次数var percentage = 0; //滚动百分比var progressText ='';//进度条信息var myTm = Ext.TaskMgr.start({run:function(){count++;if(count>10){myBox.hide();}//进度条进度percentage = count/10;progressText = '当前完成'+percentage*100+'%';myBox.updateProgress(percentage,progressText,'当前时间:'+new Date().format('y-m-d g:i:s a'));},interval:1000 //1 second});Ext.TaskMgr.start(myTm);*///--------------------------------------------------});