热门:网页模板.net视频教程JQueryMVCjsonExtJs源码示例三级联动JQuery菜单
您现在的位置:.Net中文社区>> AJAX编程>>正文内容

jQuery+jqmodal弹出窗口的制作

发布时间:2010年06月15日点击数: 佚名

先上图,最终效果如下

image

点击“信息确认”

image

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

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

所以选择了jQuery+jqmodal实现

实现方法如下

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

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

  1. /*div.whiteOverlay { background: url(dialog/jqmBG.gif) white; }*/ 
  2. div.jqDrag {cursormove;} 
  3.  
  4. /* jqmModal dialog CSS courtesy of; 
  5.   Brice Burgess <bhb@iceburg.net> */ 
  6.  
  7. div.jqmDialog { 
  8.   displaynone
  9.      
  10.     positionfixed
  11.     top: 106px
  12.     left: 50%
  13.      
  14.     margin-left-450px
  15.   width900px
  16.  
  17.   overflowhidden
  18.   font-family:verdana,tahoma,helvetica
  19.  
  20. /* Fixed posistioning emulation for IE6 
  21.      Star selector used to hide definition from browsers other than IE6 
  22.      For valid CSS, use a conditional include instead */ 
  23. * html div.jqmDialog { 
  24.      positionabsolute
  25.      top: expression((document.documentElement.scrollTop || document.body.scrollTop) + Math.round(17 * (document.documentElement.offsetHeight || document.body.clientHeight) / 100) + 'px'); 
  26.  
  27.  
  28. /* [[[ Title / Top Classes ]]] */ 
  29. div.jqmdTC {  
  30.   background#d5ff84 url(dialog/sprite.gif) repeat-x 0px -82px;  
  31.   color#528c00
  32.   padding7px 22px 5px 5px
  33.   font-family:"sans serif",verdana,tahoma,helvetica
  34.   font-weightbold
  35.   * zoom: 1
  36. div.jqmdTL { background:  url(dialog/sprite.gif) no-repeat 0px -41pxpadding-left3px;} 
  37. div.jqmdTR { backgroundurl(dialog/sprite.gif) no-repeat right 0pxpadding-right3px; * zoom: 1;} 
  38.  
  39.  
  40. /* [[[ Body / Message Classes ]]] */ 
  41. div.jqmdBC { 
  42.   backgroundurl(dialog/bc.gif) repeat-x center bottom
  43.   padding7px 7px 7px
  44.   height630px
  45.   overflowauto
  46. div.jqmdBL { backgroundurl(dialog/bl.gif) no-repeat left bottompadding-left7px; } 
  47. div.jqmdBR { backgroundurl(dialog/br.gif) no-repeat right bottompadding-right7px; * zoom: 1 } 
  48.  
  49. div.jqmdMSG { color#317895font-size:large; } 
  50.  
  51.  
  52. /* [[[ Button classes ]]] */ 
  53. input.jqmdX { 
  54.   positionabsolute
  55.   right: 7px
  56.   top: 4px
  57.   padding0 0 0 19px
  58.   height19px
  59.   width0px
  60.   backgroundurl(dialog/close.gif) no-repeat top left
  61.   overflowhidden
  62. input.jqmdXFocus {background-positionbottom leftoutlinenone;} 
  63.  
  64. div.jqmdBC button, div.jqmdBC input[type="submit"] { 
  65.   margin8px 10px 4px 10px
  66.   color#777
  67.   background-color#fff
  68.   cursorpointer
  69.  
  70. div.jqmDialog input:focus, div.jqmDialog input.iefocus { background-color#eaffc3; } 

3、在网页里面建立弹出窗口的div,注意class="jqmDialog"(就是css里面隐藏的那个)
4、在这个div里面把需要显示的东东整好~~过程略:)
5、建立jquerywin.js并引用,注意放到jqmodal引用的后面,原因同上~~,代码如下:

  1. $().ready(function() { 
  2.   $('#ex3a').jqm({ 
  3.     trigger: '#ex3aTrigger'
  4.     overlay: 30, /* 0-100 (int) : 0 is off/transparent, 100 is opaque */ 
  5.     overlayClass: 'whiteOverlay'}); 
  6.      /* make dialog draggable, assign handle to title */ 
  7.    
  8.   // Close Button Highlighting. IE doesn't support :hover. Surprise? 
  9.   $('input.jqmdX'
  10.   .hover( 
  11.     function(){ $(this).addClass('jqmdXFocus'); },  
  12.     function(){ $(this).removeClass('jqmdXFocus'); }) 
  13.   .focus(  
  14.     function(){ this.hideFocus=true; $(this).addClass('jqmdXFocus'); }) 
  15.   .blur(  
  16.     function(){ $(this).removeClass('jqmdXFocus'); }); 
  17.  
  18. }); 
  19. 6、注意,里面设置了一个trigger,可以出发弹出窗口,也可以不用trigger,直接使用js出发,方法如下: 
  20. <script type="text/javascript" language=javascript> 
  21. function showjqm(){ 
  22. if(document.all.txtTIME_KUAIJI.value!=""){ 
  23. document.all.txtTIME_KUAIJI0.style.color="#317895"
  24. document.all.txtTIME_KUAIJI0.innerHTML=document.all.txtTIME_KUAIJI.value;} 
  25. else
  26. document.all.txtTIME_KUAIJI0.style.color="Red"
  27. if(document.all.txtTIME_BIRTH.value!=""){ 
  28. document.all.txtTIME_BIRTH0.style.color="#317895"
  29. document.all.txtTIME_BIRTH0.innerHTML=document.all.txtTIME_BIRTH.value;} 
  30. else
  31. document.all.txtTIME_BIRTH0.style.color="Red"
  32. if( Page_ClientValidate()) 
  33. $('#ex3a').jqmShow(); 
  34.  
  35. </script> 

7、在上面的js里面,其实和弹出窗口直接相关的只有一句$('#ex3a').jqmShow(); 其他的都是验证的信息
8、上面的一段js里面,比较重要的还有这句if( Page_ClientValidate()) ,可以在弹出窗口之前直行页面中所有验证控件的验证工作。

本站热点业务

更多模板/案例展示

关于我们 | 联系我们 | 团队日志 | 网站地图 | 网站合作