jQuery UI dialog实现dialog弹框显示

简介:       实现弹框,比较精美的jQuery.ui.*;来实现,弹框显示:       jsp页面代码[jqueryuidialog.jsp]: <%@ page language="java" import="java.util.*" pageEncoding="GBK"%><%String path = request.getContextPath();St

      实现弹框,比较精美的jQuery.ui.*;来实现,弹框显示:

      jsp页面代码[jqueryuidialog.jsp]:

<%@ page language="java" import="java.util.*" pageEncoding="GBK"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html>
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>jQuery UI dialog</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/tsjs/jqueryui/css/jquery.ui.all.css">
	<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/tsjs/jqueryui/css/demos.css">

	<style type="text/css">
		.ui-widget-header{background-image:none;background-color:#EFF9FE} 
		.ui-widget-header{font-size:15px;}
	</style>
	<script type="text/javascript" src="${pageContext.request.contextPath }/tsjs/jquery-1.11.1.js"></script>	
	<script type="text/javascript" src="${pageContext.request.contextPath }/tsjs/jqueryuidialog.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath }/tsjs/jqueryui/js/jquery.bgiframe-2.1.2.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath }/tsjs/jqueryui/js/jquery.ui.core.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath }/tsjs/jqueryui/js/jquery.ui.widget.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath }/tsjs/jqueryui/js/jquery.ui.mouse.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath }/tsjs/jqueryui/js/jquery.ui.button.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath }/tsjs/jqueryui/js/jquery.ui.draggable.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath }/tsjs/jqueryui/js/jquery.ui.position.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath }/tsjs/jqueryui/js/jquery.ui.dialog.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath }/tsjs/jqueryui/js/jquery.ui.effect.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath }/tsjs/jqueryui/js/demo.js"></script>
  </head>
  
  <body>
    <center>
    	<div><input type="text" style="border:0px solid #FFFFFF;" id="dialogmsg" name="dialogmsg" value="Dialog" /></div>
    	<div><input type="button" id="dialogbt" name="dialogbt" value="Dialog" /></div>
    </center>
    	<div id="dialog"></div>
  </body>
</html>

js代码:

$(document).ready(function(){
	$("#dialogmsg").val("请点击确认dialog");
	$("#dialogbt").click(function(){
		var msghtml = 
			"<table>\n" +
			"  <tr>\n" + 
			"    <td rowspan=\"2\"><img src=\"tsimg/loading.gif\" title=\"maven\" /></td>\n" + 
			"    <td>可可爱</td>\n" + 
			"  </tr>\n" + 
			"  <tr>\n" + 
			"    <td>474893293223324588345</td>\n" + 
			"  </tr>\n" + 
			"</table>";
		dialogS(msghtml,function(){
			$("#dialogmsg").val("确认完毕");
		});
	});
});
function dialogS(msg,callback){
	$("#dialog").html(msg);
	$("#dialog").dialog({
		autoOpen:true,
		height:350,
		width:400,
		modal:true,
		title:'确认',
		buttons:{
			"[yes]":function(){
				$(this).dialog("close");
				callback();
			},
			"[no]":function(){
				$(this).dialog("close");
			}
		},
		close:function(){
			$(this).dialog("close");
		}
	});
}

注:此方式实现后,ie9上代码,弹框不居中,查阅资料,自己F12调试查找:

       因为:ui-dialog下的inner style中的left=-2px;导致的,修改后发现可以居中,但没办法深入修改插件,内部style,还要兼容多种浏览器。

       最终解决:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">修改为<!DOCTYPE html>居中显示了。(“可能”在特殊情况,提交后台数据为null)

效果图:

目录
相关文章
|
JSON 前端开发 JavaScript
【前端】使用jQuery封装一套UI组件 - 级联选择器组件
本篇文章来讲解下级联选择器组件 级联选择器,在实际项目中也是比较常用的组件,比如:省市区三级关联,上下级联动等 最后面会附上全部代码
1205 0
|
8月前
|
JavaScript 前端开发
前端学习笔记202306学习笔记第五十四天-react.js & material-ui之Dialog表单提交,ICon样式事件,删除功能5
前端学习笔记202306学习笔记第五十四天-react.js & material-ui之Dialog表单提交,ICon样式事件,删除功能5
28 0
|
5月前
jquery-easyui和jquery-ui的slider冲突解决
jquery-easyui和jquery-ui的slider冲突解决
|
8月前
|
JavaScript 前端开发
前端学习笔记202306学习笔记第五十四天-react.js & material-ui之Dialog表单提交,ICon样式事件,删除功能3
前端学习笔记202306学习笔记第五十四天-react.js & material-ui之Dialog表单提交,ICon样式事件,删除功能3
31 0
|
8月前
|
JavaScript 前端开发
前端学习笔记202306学习笔记第五十四天-react.js & material-ui之Dialog表单提交,ICon样式事件,删除功能1
前端学习笔记202306学习笔记第五十四天-react.js & material-ui之Dialog表单提交,ICon样式事件,删除功能1
26 0
|
8月前
|
JavaScript 前端开发
前端学习笔记202306学习笔记第五十三天-react.js & material-ui之Dialog表单提交,ICon样式事件,删除功能6
前端学习笔记202306学习笔记第五十三天-react.js & material-ui之Dialog表单提交,ICon样式事件,删除功能6
45 0
|
8月前
|
JavaScript 前端开发
前端学习笔记202306学习笔记第五十三天-react.js & material-ui之Dialog表单提交,ICon样式事件,删除功能5
前端学习笔记202306学习笔记第五十三天-react.js & material-ui之Dialog表单提交,ICon样式事件,删除功能5
43 0
|
JavaScript 前端开发 程序员
【前端】使用jQuery封装一套UI组件 - 是和否滑动切换组件
本篇文章来讲解下是和否的滑动切换组件 切换滑动组件,使用的场景实际上就是一个开和关的场景,一般有是和否,开和关,禁用和启用等等,只需要设置0和1即可
119 0
|
JavaScript 前端开发 程序员
【前端】使用jQuery封装一套UI组件 - 可编辑下拉框组件
下拉框也是比较常用的组件,对应原生的下拉标签就是select 本篇文章就来讲讲可编辑下拉框组件的封装过程
331 0
|
JavaScript 前端开发 程序员
【前端】使用jQuery封装一套UI组件 - 移动端时间选择组件
【首先要声明一点,技术不分好坏,能用好就行,不用鄙视老技术】 今天要给大家展示的是移动端时间选择组件 最开始,看到比较新颖的移动端时间选择组件是在某款手机上,分年月日下拉选择,UI界面也挺好看的 除了讲解实现的步骤以及关键点,文章最后面会有完整的代码
201 0

热门文章

最新文章

相关课程

更多