window.open 打开全屏窗口

本文介绍了一种通过JavaScript实现网页全屏打开的方法。利用`window.open`方法中的`features`参数,结合屏幕尺寸调整新窗口的大小,使之接近全屏状态。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1,利用winID = window.open(url,name,features,replace); 中的features中的属性来使新窗口全屏化

2,应用领域,需要全屏显示网页的页面。

代码如下:

 

 

ExpandedBlockStart.gif代码
 1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 2 <html xmlns="http://www.w3.org/1999/xhtml">
 3 <head>
 4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 5 <title>无标题文档</title>
 6 
 7 <script language="javascript">
 8 
 9  var winID = null;
10   function openFullWindow(url,winname)
11   {
12      var strFeatures = "left=0,screenX=0,top=0,screenY=0";  
13      if (window.screen)
14      {
15          //获取屏幕的分辨率
16           var maxh = screen.availHeight-30;
17           var maxw = screen.availWidth-10;
18           strFeatures += ",height="+maxh;
19           strFeatures += "innerHeight"+maxh;
20            strFeatures += ",width="+maxw;
21           strFeatures += "innerwidth"+maxw;
22      }
23      else
24      {
25          strFeatures +=",resizable"
26          
27      }
28      winID = window.open(url,winname,strFeatures);
29      
30   }
31 
32 
33 </script>
34 
35 
36 
37 </head>
38 
39 <body>
40 <h2>打开全屏窗口</h2>
41 <form>
42    <input type="button" value="打开全新窗口" onclick="openFullWindow('windowTime.html','JS')" />
43  
44 </form>
45 
46 </body>
47 </html>
48 

 

    var maxh = screen.availHeight-30;
          var maxw = screen.availWidth-10;

以上这两句可以设置窗口的大小

 

总结:碰到的问题onclick="openFullWindow('windowTime.html','JS')" 中的windowTime.html忘记使用单引号。

 

 

转载于:https://www.cnblogs.com/85538649/archive/2010/04/19/Fullscreen.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值