让页面打开即全屏显示方法!

本文介绍了一种使用JavaScript实现的全屏窗口打开方法。通过检测屏幕尺寸并相应地调整弹出窗口的参数,该方法能够确保窗口以接近全屏的方式显示,同时根据不同屏幕大小进行适配。

function openFullScreen(OpenUrl)
{
 var Pop;
            if (self.screen) {
            sw = screen.width;
            sh = screen.height;
   w = sw-10; // to center: use desired width
   h = sh - 70; // to center: use desired height
   cx = 0;  // to center: (.5*sw) - (w*.5)
   cy = 0; // to center: (.5*sh) - (h*.5)

      var  dimentions_and_such = 'width='+w+','+'height='+h+',' + 'screenX=' +cx+','+'screenY='+cy+','+'left='+cx+','+'top='+cy+',toolbar=0,status=0,menubar=0,resizable=0';
      var  dimentions_and_such1 = 'scrollbars=0,width='+w+','+'height='+h+',' + 'screenX=' +cx+','+'screenY='+cy+','+'left='+cx+','+'top='+cy+',toolbar=0,status=0,fullscreen=1,menubar=0,resizable=0';
  if (screen.width < 900)
  {
   Pop=window.open(OpenUrl,"","toolbar=0,location=0,fullscreen=1,directories=0,status=0,menubar=0,scrollbars=0,resizable=0");
  }
  else if (screen.width > 1200)
  {
   Pop=window.open(OpenUrl,"",dimentions_and_such1);
  }
  else
  {
   Pop=window.open(OpenUrl,"",dimentions_and_such1);
  }
 }
}

//打开其他页
openFullScreen(http://gavincome.cnblogs.com)
//打开本页
openFullScreen(location.href)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值