踩坑系列之window.open弹窗使用

window.open水平居中显示


预计使用layer的弹窗,打开外链,可是点击操作之后,就会跳转其他界面,会改变页面框架的路径,可能是我学艺不精,对layer理解不够透彻,以至于无法控制,之后改用window.open()方法,来控制界面。

function sWindow(url,data) {
    var $windowObj  = null;
    var name='title';  //网页名称,可为空;
    var iWidth=550;    //弹出窗口的宽度;
    var iHeight=620;  //弹出窗口的高度;
    //获得窗口的垂直位置
    var iTop = (window.screen.availHeight - 30 - iHeight) / 2;
    //获得窗口的水平位置
    var iLeft = (window.screen.availWidth - 10 - iWidth) / 2;
    $winObj = window.open(url, name, 'height=' + iHeight + ',,innerHeight=' + iHeight + ',width=' + iWidth + ',innerWidth=' + iWidth + ',top=' + iTop + ',left=' + iLeft + ',status=no,toolbar=no,menubar=no,location=no,resizable=no,scrollbars=0,titlebar=no');

    var loop = setInterval(function() {
        if($winObj != null && $winObj .closed) {
            clearInterval(loop);
            //add回调函数
            
          
        }
    }, 500);
}

window.open 弹出新窗口的命令;
  url:弹出窗口的文件名或者链接路径;
  name:弹出窗口的名字(不是文件名),非必须,可用空’'代替;
  height:窗口高度;
  width:窗口宽度;
  top:窗口距离屏幕上方的象素值;
  left:窗口距离屏幕左侧的象素值;
  toolbar:是否显示工具栏,yes为显示,no为隐藏;
  menubar,scrollbars 表示菜单栏和滚动栏。
  resizable:是否允许改变窗口大小,yes为允许;
  location:是否显示地址栏,yes为允许;
  status:是否显示状态栏内的信息(通常是文件已经打开),yes为允许;

ps:此博文后期会有更新!

如有不足之处,请指出,谢谢!
每天进步一点点。

你可能感兴趣的:(踩坑系列,前端)