首页 > 开发 > 综合 > 正文

怎么让网页全屏显示?

2020-09-19 11:00:12
字体:
来源:转载
供稿:网友

最常见的是使用window.open的方法,直接打开全屏网页:

<script>
<!--
function fullwin(){
window.open(
"bigpage.html","bfs","fullscreen,scrollbars")
}
//-->
</script>

<center>
<form>
<input type="button" onclick="fullwin()" value="open full screen window">
</form>
</center> 

另外,如果想让已经打开的网页全屏,有以下两种方法:

1.使用activex

<html>
<head>
<title>test</title>
<script language="javascript">
function fkey(){
     
var wsshell = new activexobject('wscript.shell')
     wsshell.sendkeys(
'{f11}');
}
</script>
</head>
<body>
<href="javascript:fkey()">to full</a>
</body>
</html>

2.使用window.open模拟当前页:

<script language="javascript">   
function   tofull(){   
  
if(window.name=="fullscreen")return;   
  
var a =window.open("","fullscreen","fullscreen=yes")   
  a.location 
= window.location.href   
  window.opener
=null   
  window.close()   
}   
</script>   
<html>   
<body>   
<input type=button value="full" onclick=tofull()>   
</body>   
</html>   
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表