• js 控制打开网页窗口的大小位置 sk


    1. 打开窗口即最大化

    self.moveTo(0,0)
    self.resizeTo(screen.availWidth,screen.availHeight)
    

    2. 自定义窗口方法

    // url String 域名
    // title String 标题
    // w String 宽度
    // h String 高度
    
    export default function openWindow(url,title,w,h) {
          //Fixes dual-screen position                             Most browsers        Firefox
          const dualScreenLeft =
            window.screenLeft !== undefined ? window.screenLeft : screen.left;
            const dualScreenTop =
            window.screenTop !== undefined ? window.screenTop : screen.top;
    
          const width = window.innerWidth
            ? window.innerWidth
            : document.documentElement.clientWidth
            ? document.documentElement.clientWidth
            : screen.width;
          const height = window.innerHeight
            ? window.innerHeight
            : document.documentElement.clientHeight
            ? document.documentElement.clientHeight
            : screen.height;
    
          const left = width / 2 - w / 2 + dualScreenLeft;
          const top = height / 2 - h / 2 + dualScreenTop;
    
          const newwindow = window.open(
            url,
            title,
            `toolbar=no, scrollbars=no, resizable=yes, menubar=no, status=no, location=no, center=yes, copyhistory=no ,width=${w}, height=${h}, left=${left}, top=${top}`
          );
    
          // Puts focus on the newWindow
          if (window.focus) {
            newwindow.focus();
          }
    
          //   window.open 弹出新窗口的命令;
          //   'page.html' 弹出窗口的文件名;
          //   'newwindow' 弹出窗口的名字(不是文件名),非必须,可用空''代替;
          //   height=100 窗口高度;
          //   width=400 窗口宽度;
          //   top=0 窗口距离屏幕上方的象素值;
          //   left=0 窗口距离屏幕左侧的象素值;
          //   toolbar=no 是否显示工具栏,yes为显示;
          //   menubar,scrollbars 表示菜单栏和滚动栏。
          //   resizable=no 是否允许改变窗口大小,yes为允许;
          //   location=no 是否显示地址栏,yes为允许;
          //   status=no 是否显示状态栏内的信息(通常是文件已经打开),yes为允许;
    }
    
    
  • 相关阅读:
    SRM 574 250 DIV2
    SRM 575 250 DIV2
    SRM 577 250 DIV2
    20181211-python1119作业郭恩赐
    20181207作业-郭恩赐
    python1119-20181206作业-郭恩赐提交
    python1119-20181205作业-郭恩赐提交
    python1119作业1-郭恩赐提交
    py1119_Linux学习_第二周总结
    小白都能看懂的block
  • 原文地址:https://www.cnblogs.com/xm0328/p/16189939.html
Copyright © 2020-2023  润新知