jQuery+jqmodal弹出窗口实现代码分明


Posted in Javascript onJune 14, 2010

先上图,最终效果如下

 jQuery+jqmodal弹出窗口实现代码分明

点击“信息确认”

 jQuery+jqmodal弹出窗口实现代码分明

就是弹出一个确认窗口,把已经填报的信息都放到里面看看。

信息放里面很简答,主要是弹出窗口要做得好看点。

所以选择了jQuery+jqmodal实现

实现方法如下
1、页面中引用jquery-1.4.2.js和jqModal.js,注意jQuery要在前面,因为jqmodal是以jQuery为基础的。

2、建立jqModal.css,并引用,主要是些美工的东东,注意div.jqmDialog 的 display为 none。高度和宽度要设置好,挡住下面的,好看~~,我偷个懒,把jqmodal示例的css稍微改了下:)如下:

/*div.whiteOverlay { background: url(dialog/jqmBG.gif) white; }*/ 
div.jqDrag {cursor: move;} /* jqmModal dialog CSS courtesy of; 
Brice Burgess <bhb@iceburg.net> */ 
div.jqmDialog { 
display: none; 
position: fixed; 
top: 106px; 
left: 50%; 
margin-left: -450px; 
width: 900px; 
overflow: hidden; 
font-family:verdana,tahoma,helvetica; 
} 
/* Fixed posistioning emulation for IE6 
Star selector used to hide definition from browsers other than IE6 
For valid CSS, use a conditional include instead */ 
* html div.jqmDialog { 
position: absolute; 
top: expression((document.documentElement.scrollTop || document.body.scrollTop) + Math.round(17 * (document.documentElement.offsetHeight || document.body.clientHeight) / 100) + 'px'); 
} 

/* [[[ Title / Top Classes ]]] */ 
div.jqmdTC { 
background: #d5ff84 url(dialog/sprite.gif) repeat-x 0px -82px; 
color: #528c00; 
padding: 7px 22px 5px 5px; 
font-family:"sans serif",verdana,tahoma,helvetica; 
font-weight: bold; 
* zoom: 1; 
} 
div.jqmdTL { background: url(dialog/sprite.gif) no-repeat 0px -41px; padding-left: 3px;} 
div.jqmdTR { background: url(dialog/sprite.gif) no-repeat right 0px; padding-right: 3px; * zoom: 1;} 

/* [[[ Body / Message Classes ]]] */ 
div.jqmdBC { 
background: url(dialog/bc.gif) repeat-x center bottom; 
padding: 7px 7px 7px; 
height: 630px; 
overflow: auto; 
} 
div.jqmdBL { background: url(dialog/bl.gif) no-repeat left bottom; padding-left: 7px; } 
div.jqmdBR { background: url(dialog/br.gif) no-repeat right bottom; padding-right: 7px; * zoom: 1 } 
div.jqmdMSG { color: #317895; font-size:large; } 

/* [[[ Button classes ]]] */ 
input.jqmdX { 
position: absolute; 
right: 7px; 
top: 4px; 
padding: 0 0 0 19px; 
height: 19px; 
width: 0px; 
background: url(dialog/close.gif) no-repeat top left; 
overflow: hidden; 
} 
input.jqmdXFocus {background-position: bottom left; outline: none;} 
div.jqmdBC button, div.jqmdBC input[type="submit"] { 
margin: 8px 10px 4px 10px; 
color: #777; 
background-color: #fff; 
cursor: pointer; 
} 
div.jqmDialog input:focus, div.jqmDialog input.iefocus { background-color: #eaffc3; }

3、在网页里面建立弹出窗口的div,注意class="jqmDialog"(就是css里面隐藏的那个)

4、在这个div里面把需要显示的东东整好~~过程略:)

5、建立jquerywin.js并引用,注意放到jqmodal引用的后面,原因同上~~,代码如下:

$().ready(function() { 
$('#ex3a').jqm({ 
trigger: '#ex3aTrigger', 
overlay: 30, /* 0-100 (int) : 0 is off/transparent, 100 is opaque */ 
overlayClass: 'whiteOverlay'}); 
/* make dialog draggable, assign handle to title */ // Close Button Highlighting. IE doesn't support :hover. Surprise? 
$('input.jqmdX') 
.hover( 
function(){ $(this).addClass('jqmdXFocus'); }, 
function(){ $(this).removeClass('jqmdXFocus'); }) 
.focus( 
function(){ this.hideFocus=true; $(this).addClass('jqmdXFocus'); }) 
.blur( 
function(){ $(this).removeClass('jqmdXFocus'); }); 
});

6、注意,里面设置了一个trigger,可以出发弹出窗口,也可以不用trigger,直接使用js出发,方法如下:
<script type="text/javascript" language=javascript> 
function showjqm(){ 
if(document.all.txtTIME_KUAIJI.value!=""){ 
document.all.txtTIME_KUAIJI0.style.color="#317895"; 
document.all.txtTIME_KUAIJI0.innerHTML=document.all.txtTIME_KUAIJI.value;} 
else{ 
document.all.txtTIME_KUAIJI0.style.color="Red"; 
} 
if(document.all.txtTIME_BIRTH.value!=""){ 
document.all.txtTIME_BIRTH0.style.color="#317895"; 
document.all.txtTIME_BIRTH0.innerHTML=document.all.txtTIME_BIRTH.value;} 
else{ 
document.all.txtTIME_BIRTH0.style.color="Red"; 
} 
if( Page_ClientValidate()) 
$('#ex3a').jqmShow(); 
} 
</script>

7、在上面的js里面,其实和弹出窗口直接相关的只有一句$('#ex3a').jqmShow(); 其他的都是验证的信息

8、上面的一段js里面,比较重要的还有这句if( Page_ClientValidate()) ,可以在弹出窗口之前直行页面中所有验证控件的验证工作。

Javascript 相关文章推荐
JS option location 页面跳转实现代码
Dec 27 Javascript
JQuery Easyui Tree的oncheck事件实现代码
May 28 Javascript
jquery offset函数应用实例
Nov 14 Javascript
jquery入门—数据删除与隔行变色以及图片预览
Jan 07 Javascript
javascript的内存管理详解
Aug 07 Javascript
JS字符串截取函数实例
Dec 27 Javascript
jquery sortable的拖动方法示例详解
Jan 16 Javascript
js函数调用的方式
May 06 Javascript
jQuery实现内容定时切换效果完整实例
Apr 06 Javascript
微信公众号菜单配置微信小程序实例详解
Mar 31 Javascript
深入理解React中何时使用箭头函数
Aug 23 Javascript
解决在Bootstrap模糊框中使用WebUploader的问题
Mar 22 Javascript
ExtJS 设置级联菜单的默认值
Jun 13 #Javascript
js 未结束的字符串常量错误解决方法
Jun 13 #Javascript
JSON 和 JavaScript eval使用说明
Jun 13 #Javascript
ExtJS PropertyGrid中使用Combobox选择值问题
Jun 13 #Javascript
js null undefined 空区别说明
Jun 13 #Javascript
javascript dom代码应用 简单的相册[firefox only]
Jun 12 #Javascript
DOM Scripting中的图片切换[兼容Firefox]
Jun 12 #Javascript
You might like
php中的路径问题与set_include_path使用介绍
2014/02/11 PHP
CentOS 安装 PHP5.5+Redis+XDebug+Nginx+MySQL全纪录
2015/03/25 PHP
php字符串函数学习之substr()
2015/03/27 PHP
CodeIgniter视图使用注意事项
2016/01/20 PHP
php实现数字补零的方法总结
2018/09/12 PHP
基于jquery的图片懒加载js
2010/06/30 Javascript
JQuery文字列表向上滚动的代码
2013/11/13 Javascript
jquery实现简单的banner轮播效果【实例】
2016/03/30 Javascript
更靠谱的H5横竖屏检测方法(js代码)
2016/09/13 Javascript
利用JS判断鼠标移入元素的方向
2016/12/11 Javascript
基于jQuery实现手风琴菜单、层级菜单、置顶菜单、无缝滚动效果
2017/07/20 jQuery
详解element-ui中el-select的默认选择项问题
2019/08/02 Javascript
vue 微信分享回调iOS和安卓回调出现错误的解决
2020/09/07 Javascript
[59:15]完美世界DOTA2联赛PWL S2 LBZS vs FTD.C 第一场 11.20
2020/11/20 DOTA
[05:08]DOTA2-DPC中国联赛3月6日Recap集锦
2021/03/11 DOTA
Python类的用法实例浅析
2015/05/27 Python
python读取oracle函数返回值
2016/07/18 Python
Python简单遍历字典及删除元素的方法
2016/09/18 Python
对python 树状嵌套结构的实现思路详解
2019/08/09 Python
Python paramiko模块使用解析(实现ssh)
2019/08/30 Python
Python中低维数组填充高维数组的实现
2019/12/02 Python
Django admin管理工具TabularInline类用法详解
2020/05/14 Python
python爬虫快速响应服务器的做法
2020/11/24 Python
详解使用双缓存解决Canvas clearRect引起的闪屏问题
2019/04/29 HTML / CSS
巴西独家产品和现场演示购物网站:Shoptime
2019/07/11 全球购物
请写出char *p与"零值"比较的if语句
2014/09/24 面试题
爱祖国演讲稿
2014/05/04 职场文书
计划生育证明格式范本
2014/09/12 职场文书
教师辞职书范文
2015/02/26 职场文书
居委会工作总结2015
2015/05/18 职场文书
公司仓库管理制度
2015/08/04 职场文书
2016年教师节慰问信
2015/12/01 职场文书
你为什么是穷人?可能是这5个缺点造成
2019/07/11 职场文书
2019年度政务公开考核工作总结模板
2019/11/11 职场文书
nginx作grpc的反向代理踩坑总结
2021/07/07 Servers
 Redis 串行生成顺序编码的方法实现
2022/04/03 Redis