韩国网站后缀,汕头模板建站平台,网站详情页设计,服务器上发布网站之前写过 前端screenfull实现界面全屏展示功能 突然发现自己犯傻了
其实元素js中就有全屏与取消全屏的方式 html代码如下
!DOCTYPE html
html
headtitle全屏实验/titlestyle/style
/head
bodyd…之前写过 前端screenfull实现界面全屏展示功能 突然发现自己犯傻了
其实元素js中就有全屏与取消全屏的方式 html代码如下
!DOCTYPE html
html
headtitle全屏实验/titlestyle/style
/head
bodydiv id mian style width: 100px;height: 100px;background-color: blue;button id screen全屏/buttonbutton id CancelFullScreen取消全屏/button/divscriptvar mian document.getElementById(mian);var screen document.getElementById(screen);var CancelFullScreen document.getElementById(CancelFullScreen);screen.onclick function () {mian.requestFullscreen();}CancelFullScreen.onclick function () {document.exitFullscreen();}/script
/body
/html这里 我们mian元素为主体 然后 包裹两个按钮 screen全屏按钮 设置了点击事件 通过mian元素 调用requestFullscreen实现mian元素占满全屏 点击全屏 screen 按钮效果如下 然后 CancelFullScreen按钮的点击事件 就调用了 document对象的exitFullscreen方法 调用后 不管谁在全屏 都会立刻退出