用js怎样实现打开网页时就全屏显示,要支持chrome,Firefox,IE等主流浏览器,求大神帮忙啊!

JavaScript010

用js怎样实现打开网页时就全屏显示,要支持chrome,Firefox,IE等主流浏览器,求大神帮忙啊!,第1张

您好!很高兴为您答疑!

实现窗口全屏(F11效果),只需在下面属性中加一条fullscreen = yes即可

<script>

<!--

function windowopen(){

var target="http://play.zol.com.cn"

newwindow=window.open("","","scrollbars")

if (document.all){

newwindow.moveTo(0,0)

newwindow.resizeTo(screen.width,screen.height)

}

newwindow.location=target

}

//-->

</script>

<form>

<input type="button" onClick="windowopen()" value="全屏显示" name="button">

</form>

您可以在火狐社区了解更多内容。希望我的回答对您有所帮助,如有疑问,欢迎继续在本平台咨询。

document.addEventListener("fullscreenchange", function( event ) {

  if (document.fullscreenElement) {

    console.log('进入全屏')

  } else {

    console.log('退出全屏')

  }})

可以这样判断。但是旧版IE是不支持的。

需要准备的材料分别有:电脑、html编辑器、浏览器。

1、首先,打开html编辑器,新建html文件,例如:index.html。

2、在index.html中的<script>标签,输入js代码:

var h = $(window).height()

var w = $(window).width()

window.open ('index.php', 'newwindow', 'height=' + h + ', width=' + w + ', top=0, left=0, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=n o, status=no')

3、浏览器运行index.html页面,此时成功打开了一个全屏可以改变大小的最大化窗口。