您当前的位置: 首页 >  ui

漏刻有时

暂无认证

  • 0浏览

    0关注

    717博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

layui嵌套弹出模态框的Blocked a frame with origin null from的解决方案

漏刻有时 发布时间:2020-12-16 12:01:07 ,浏览量:0

在layui开发的过程中,需要在弹出层里再次调用弹出层。

  1. layer.open,父页面封装弹出函数;
  2. top.layer.open,子页面封装弹出函数;

top.layer.open(),无法使用本地"files://"协议打开的,需要http协议。

否则提示:

Uncaught SecurityError: Blocked a frame with origin "null" from accessing a frame with origin "null". Protocols, domains, and ports must match.
函数封装
/*弹出窗口*/
function previewPages(url, title) {
    layer.open({
        type: 2,
        shade: 0.6,
        area: ['600px', '390px'],//弹出模态框尺寸;
        shadeClose: true,
        scrollbar: false,
        maxmin: true,
        title: title, //显示标题
        content: url, //捕获的元素
        cancel: function () {
            //layer.msg('捕获就是从页面已经存在的元素上,包裹layer的结构', { time: 5000, icon: 6 });
        }
    });
}

//嵌套弹出模态框;
function topPop(url, title) {
    top.layer.open({
        type: 2,
        shade: 0.6,
        area: ['800px', '450px'],//弹出模态框尺寸;
        shadeClose: true,
        scrollbar: false,
        maxmin: true,
        title: title, //显示标题
        content: url, //捕获的元素
        cancel: function () {
            //layer.msg('捕获就是从页面已经存在的元素上,包裹layer的结构', { time: 5000, icon: 6 });
        }
    });
}

//普通窗口;
function winPop(url) {
    window.open(url, '_blank', 'width=' + (window.screen.availWidth - 10) + ',height=' + (window.screen.availHeight - 30) + ',top=0,left=0,toolbar=no,menubar=no,scrollbars=no, resizable=no,location=no, status=no')
}

Done!

关注
打赏
1661217259
查看更多评论
立即登录/注册

微信扫码登录

0.0679s