分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 教程案例

js实现全屏

发布时间:2023-09-06 01:39责任编辑:赖小花关键词:js

 

document.getElementById("btn").onclick=function(){  var elem = document.getElementById("content"); ???requestFullScreen(elem); ???/* ????注意这里的样式的设置表示全屏显示之后的样式, ????退出全屏后样式还在, ????若要回到原来样式,需在退出全屏里把样式还原回去 ????(见写法三) ????*/ ???elem.style.height = ‘800px‘; ???elem.style.width = ‘100%‘; }; function requestFullScreen(element) {   var requestMethod = element.requestFullScreen || element.webkitRequestFullScreen || element.mozRequestFullScreen || element.msRequestFullScreen; ?  if (requestMethod) { ????  requestMethod.call(element); ?  }else if (typeof window.ActiveXObject !== "undefined") { ??   var wscript = new ActiveXObject("WScript.Shell"); ??   ?if (wscript !== null) { ???     wscript.SendKeys("{F11}"); ?   ??} ????} }

  代码来源:http://www.jb51.net/article/101692.htm。

  这个可以使选定的内容全屏而不是页面上所有的内容全屏,不过这个有个缺点是高度不能铺满。

js实现全屏

原文地址:https://www.cnblogs.com/yaoya/p/8350561.html

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved