• 首页 首页 icon
  • 工具库 工具库 icon
    • IP查询 IP查询 icon
  • 内容库 内容库 icon
    • 快讯库 快讯库 icon
    • 精品库 精品库 icon
    • 问答库 问答库 icon
  • 更多 更多 icon
    • 服务条款 服务条款 icon

JQ: 有点历史框架Grails;1、弹出子窗口<frame>,2、弹出子窗口parent.layer.open;操作实现,关闭等实际开发遇到问题

武飞扬头像
夜雨星光~
帮助4

一:

第一个问题:由于对于前端js知识不是很熟悉,在开始写弹窗时不知道使用那种方法,后面找到实现弹窗方法:

1、需要引入<g:javascript src="https://blog.csdn.net/weixin_46567616/article/details/jquery/jquery.js"/>,但不能再页面重复引入<g:javascript src="https://blog.csdn.net/weixin_46567616/article/details/jquery/jquery.min.js"/>,否则会报错(实现不了)

2、在主页面预留位置给子窗口,例如定义:

  1.  
    <div>
  2.  
    .......
  3.  
    <div id ='win'></div>
  4.  
    </div>

3、在按钮(自定义)处点击后在函数处实现:

  1.  
    function importData(){
  2.  
     
  3.  
    jQuery('#win').window({
  4.  
    title : '批量导入',
  5.  
    width:800,
  6.  
    height:440,
  7.  
    modal:true, //true表示弹窗出现后主页面无法操作
  8.  
    minimizable :false,
  9.  
    maximizable:false,
  10.  
    collapsible:false,
  11.  
    content:"<iframe src='https://blog.csdn.net/weixin_46567616/article/details/${request.contextPath}/xxx/xxx' height='100%' width='100%' frameborder='0px' style='border: solid 0px;' ></iframe>",
  12.  
    onClose:function(){
  13.  
    $('#lt').datagrid('reload');
  14.  
    }
  15.  
    });
  16.  
    }
学新通

注意:代码中的src表示可跳转到子窗口内容的路径(本人是利用后台action进行跳转)

4、弹窗出现后如何更换标题,子窗口内容,高度,宽度等等:

  1.  
    parent.$('#win').window("setTitle", "修改用户");//更换标题
  2.  
    parent.$("#win").window('resize', {width:770, height:550});//更换宽高
  3.  
    parent.$("#win").window('center');//更换出现位置

子窗口内容可以在子窗口页面上直接跳转

5、如何关闭

  1.  
    //关闭窗口(#win是主页面的div)
  2.  
    parent.jQuery('#win').window('close')
  3.  
    //主页面重新加载
  4.  
    parent.location.reload();

额外知识:

函数表示加载页面随即加载该函数,可以在里面做初始化定时器等等功能。

  1.  
    <script>
  2.  
     
  3.  
    jQuery(document).ready(function (){
  4.  
    time();
  5.  
     
  6.  
    })
  7.  
     
  8.  
    function time(){
  9.  
    if(${flash.message!=null}){
  10.  
    timeOutValue = timeOutValue - 1;
  11.  
    if (timeOutValue <= 0) {
  12.  
    timeOutValue = maxTime;
  13.  
    jQuery("#msg").hide();
  14.  
    }
  15.  
    setTimeout("time()", 1000); //每隔一秒监听一次
  16.  
    }
  17.  
    }
  18.  
     
  19.  
    </script>
学新通

操作进行转圈:

  1.  
    <style>
  2.  
    .toast {
  3.  
    display: none;
  4.  
    position: fixed;
  5.  
    flex-direction: column;
  6.  
    justify-content: center;
  7.  
    align-items: center;
  8.  
    width: 9rem;
  9.  
    height: 9rem;
  10.  
    left: 50%;
  11.  
    top: 50%;
  12.  
    transform: translate(-50%, -50%);
  13.  
    background-color: rgba(0,0,0,0.2);
  14.  
    border-radius: 1rem;
  15.  
    color: #f0f0f0;
  16.  
    font-size: 2.5rem;
  17.  
    }
  18.  
    </style>
  19.  
    <script>
  20.  
    function onclick(){
  21.  
    //展示转圈
  22.  
    var toast = document.getElementById("toast");
  23.  
    toast.style.display="flex";
  24.  
    }
  25.  
    function ok(){
  26.  
    //关闭转圈展示
  27.  
    var toast = document.getElementById("toast");
  28.  
    toast.style.display="none";
  29.  
    }
  30.  
    </script>
  31.  
    <html>
  32.  
    ......
  33.  
    <div class="toast" id="toast">
  34.  
    <span ><img src="${request.contextPath}\css\colorbox\images\loading.gif"></span>
  35.  
    <span>正在处理数据,请稍候...</span>
  36.  
    </div>
  37.  
    </html>
学新通

附件:动态转圈的gif图

学新通

二:

需要主页面导入弹窗的组件:

   

  1.  
    <!--parent.layer.open弹窗的组件-->
  2.  
    <g:javascript src="layui/layui-2.2.5/layui.all.js"/>
  1.  
    //本窗口是在已弹出窗口基础上点击按钮再次弹窗(还是在父类页面基础上弹窗)
  2.  
    parent.layer.open({
  3.  
    id: '666'
  4.  
    type: 2,
  5.  
    title: '',
  6.  
    shadeClose: false,
  7.  
    shade: 0.8,
  8.  
    area: ['530px', '370px'],
  9.  
    content: '${request.contextPath}/xxx'
  10.  
    });

更换弹窗标题:

  1.  
    var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
  2.  
    parent.layer.title('批量导入', index) //再改变当前层的标题

关闭弹窗窗口:

  1.  
    var index = parent.layer.getFrameIndex(window.name);
  2.  
    parent.layer.close(index);

主页面重新加载

 parent.location.reload();

这篇好文章是转载于:学新通技术网

  • 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
  • 本站站名: 学新通技术网
  • 本文地址: /boutique/detail/tanhiajeii
系列文章
更多 icon
同类精品
更多 icon
继续加载