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

JavaScript017

用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是不支持的。