当前位置: 首页 > news >正文

外贸网站做推广本周新闻热点

外贸网站做推广,本周新闻热点,做网站本溪,学网站开发学费多少文章目录 需求分析 需求 上节我们研究了如何将页面中的指定 div 下载为图片:跳转查看 本节演技一下如何将 DIV 全屏展示 全屏展示某一个 DIV 分析 其实就是模拟键盘动作 F11 var element document.getElementById(pic) var requestMethod element.requestFullS…

文章目录

    • 需求
    • 分析

需求

上节我们研究了如何将页面中的指定 div 下载为图片:跳转查看
本节演技一下如何将 DIV 全屏展示

全屏展示某一个 DIV
在这里插入图片描述

在这里插入图片描述

分析

  • 其实就是模拟键盘动作 F11
var element = document.getElementById('pic')
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}')}
}
  • demo1.html
<!DOCTYPE html>
<html><head><meta charset="UTF-8"><title>全屏展示</title><style>.top {margin: 15px;
}
.main {width: 100%;height: 1000px;display: flex;
}
.left {width: 50%;height: 60%;background: gray;padding: 20px;
}
.left-son {width: 80%;height: 50%;margin: 15px;background: red;
}
.right {width: 50%;height: 60%;background: #dddddd;
}
/* 针对dom的全屏设置 */
.left:-webkit-full-screen {background: #fff;
}
/* 全屏属性 */
:-webkit-full-screen {
}
:-moz-full-screen {
}
:-ms-fullscreen {
}
/* 全屏伪类 当前chrome:70 不支持 */
:full-screen {
}
:fullscreen {/* IE11支持 */
}</style>
</head><body><!--* @Author: OBKoro1* @Github: https://github.com/OBKoro1* @Date: 2018-11-15 18:49:33* @LastEditors: OBKoro1* @LastEditTime: 2018-11-23 18:20:36* @Description: 浏览器全屏class类演示demo--><div class="top"><button onclick="leftScreen()">左边全屏</button><button onclick="rightScreen()">右边全屏</button></div><div class="main"><div class="left"><button onclick="redScreen()">红色全屏</button><button onclick="exitScreen()">退出全屏</button><div class="left-son"><button onclick="exitScreen()">红色退出全屏</button><span>左边的内容</span></div></div><div class="right">右边的内容</div></div>
</body></html><script>class fullScreen {/*** @description: 全屏初始化* @param {Function} fn 用户浏览器不支持全屏的回调*/constructor(fn) {this.prefixName = ""; // 浏览器前缀this.isFullscreenData = true; // 浏览器是否支持全屏this.isFullscreen(fn);}/*** @description: 将传进来的元素全屏* @param {String} domName 要全屏的dom名称*/Fullscreen (domName) {const element = document.querySelector(domName);const methodName =this.prefixName === ""? "requestFullscreen": `${this.prefixName}RequestFullScreen`;element[methodName]();}// 退出全屏exitFullscreen () {const methodName =this.prefixName === ""? "exitFullscreen": `${this.prefixName}ExitFullscreen`;document[methodName]();}/*** @description: 监听进入/离开全屏* @param {Function} enter 进入全屏的回调*  @param {Function} quit 离开全屏的回调*/screenChange (enter, quit) {if (!this.isFullscreenData) return;const methodName = `on${this.prefixName}fullscreenchange`;document[methodName] = e => {if (this.isElementFullScreen()) {enter && enter(e); // 进入全屏回调} else {quit && quit(e); // 离开全屏的回调}};}/*** @description: 浏览器无法进入全屏时触发,可能是技术原因,也可能是用户拒绝:比如全屏请求不是在事件处理函数中调用,会在这里拦截到错误* @param {Function} enterErrorFn 回调*/screenError (enterErrorFn) {const methodName = `on${this.prefixName}fullscreenerror`;document[methodName] = e => {enterErrorFn && enterErrorFn(e);};}/*** @description: 是否支持全屏+判断浏览器前缀* @param {Function} fn 不支持全屏的回调函数 这里设了一个默认值*/isFullscreen (fn) {let fullscreenEnabled;// 判断浏览器前缀if (document.fullscreenEnabled) {fullscreenEnabled = document.fullscreenEnabled;} else if (document.webkitFullscreenEnabled) {fullscreenEnabled = document.webkitFullscreenEnabled;this.prefixName = "webkit";} else if (document.mozFullScreenEnabled) {fullscreenEnabled = document.mozFullScreenEnabled;this.prefixName = "moz";} else if (document.msFullscreenEnabled) {fullscreenEnabled = document.msFullscreenEnabled;this.prefixName = "ms";}if (!fullscreenEnabled) {this.isFullscreenData = false;fn && fn(); // 执行不支持全屏的回调}}/*** @description: 检测有没有元素处于全屏状态* @return 布尔值*/isElementFullScreen () {const fullscreenElement =document.fullscreenElement ||document.msFullscreenElement ||document.mozFullScreenElement ||document.webkitFullscreenElement;if (fullscreenElement === null) {return false; // 当前没有元素在全屏状态} else {return true; // 有元素在全屏状态}}}let full = new fullScreen(() => {console.log("不支持");});full.screenError(e => {console.log("进去全屏失败:", e);});// 全屏请求必须在事件处理函数中调用,否则将会被拒绝。full.Fullscreen(".left"); // 触发进去全屏失败回调const obj = {enter: e => {// 如果退出全屏 退出的还是全屏状态,将会触发进入全屏的回调,这种情况比较少 注意一下console.log("进入全屏", e);},quit: e => {console.log("退出全屏", e);// 通常不会出现嵌套的情况}};full.screenChange(obj.enter, obj.quit);function leftScreen () {full.Fullscreen(".left");}function rightScreen () {full.Fullscreen(".right");}function redScreen () {full.Fullscreen(".left-son");}// 退出全屏 退出到上次的状态function exitScreen () {full.exitFullscreen();}
</script>
  • demo2.html
<html>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style>#container {position: absolute;top: 0;left: 0;bottom: 0;right: 0;background-color: red;}
</style><body><div id="container"><div id="content" style="margin:0 auto;height:45%;width:80%px; background:orange;"><button id="btn">全屏</button><button id="close">退出</button><h1>js控制页面部分区域的全屏展示和退出全屏显示</h1></div></div>
</body>
<script language="JavaScript">var btn = document.getElementById("btn");btn.onclick = function () {var elem = document.getElementById("content");requestFullScreen(elem);};var close = document.getElementById("close");close.onclick = function () {exitFullscreen();};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}");}}}function exitFullscreen () {if (document.exitFullscreen) {document.exitFullscreen();} else if (document.msExitFullscreen) {document.msExitFullscreen();} else if (document.mozCancelFullScreen) {document.mozCancelFullScreen();} else if (document.webkitExitFullscreen) {document.webkitExitFullscreen();}}</script></html>

文章转载自:
http://parlor.c7629.cn
http://antipasto.c7629.cn
http://forlorn.c7629.cn
http://crimple.c7629.cn
http://popularize.c7629.cn
http://crust.c7629.cn
http://biscayne.c7629.cn
http://fastuously.c7629.cn
http://pdu.c7629.cn
http://cabochon.c7629.cn
http://epidermoid.c7629.cn
http://sheeny.c7629.cn
http://menthene.c7629.cn
http://anqing.c7629.cn
http://sorely.c7629.cn
http://disinheritance.c7629.cn
http://triphibious.c7629.cn
http://encyclopedize.c7629.cn
http://digitiform.c7629.cn
http://ritz.c7629.cn
http://expressively.c7629.cn
http://sauce.c7629.cn
http://puerperium.c7629.cn
http://menstrual.c7629.cn
http://encephalous.c7629.cn
http://detect.c7629.cn
http://nephology.c7629.cn
http://nimbus.c7629.cn
http://laocoon.c7629.cn
http://bromeliad.c7629.cn
http://dean.c7629.cn
http://paradisiac.c7629.cn
http://karelian.c7629.cn
http://summarization.c7629.cn
http://aeroflot.c7629.cn
http://sublease.c7629.cn
http://naida.c7629.cn
http://educable.c7629.cn
http://marsupialise.c7629.cn
http://reconcilable.c7629.cn
http://shaven.c7629.cn
http://unneighborly.c7629.cn
http://foreshots.c7629.cn
http://introspection.c7629.cn
http://occultism.c7629.cn
http://teaser.c7629.cn
http://profligacy.c7629.cn
http://anabaptistical.c7629.cn
http://eelpot.c7629.cn
http://goldeye.c7629.cn
http://fireflaught.c7629.cn
http://tsushima.c7629.cn
http://bds.c7629.cn
http://thyrotrophic.c7629.cn
http://throwster.c7629.cn
http://secretiveness.c7629.cn
http://tailwagging.c7629.cn
http://cordially.c7629.cn
http://anhydrite.c7629.cn
http://runed.c7629.cn
http://prelaw.c7629.cn
http://eidetic.c7629.cn
http://attagal.c7629.cn
http://caressive.c7629.cn
http://spinstress.c7629.cn
http://bms.c7629.cn
http://mount.c7629.cn
http://ampholyte.c7629.cn
http://cooperativity.c7629.cn
http://silicone.c7629.cn
http://tedder.c7629.cn
http://subjunction.c7629.cn
http://codlinsandcream.c7629.cn
http://ruthenium.c7629.cn
http://moonwatcher.c7629.cn
http://epiphytotic.c7629.cn
http://towpath.c7629.cn
http://superstratum.c7629.cn
http://gunpaper.c7629.cn
http://electronic.c7629.cn
http://durkheimian.c7629.cn
http://thievish.c7629.cn
http://budgerigar.c7629.cn
http://weigh.c7629.cn
http://quintuple.c7629.cn
http://typecasting.c7629.cn
http://unmixed.c7629.cn
http://span.c7629.cn
http://dorking.c7629.cn
http://tetrafluoride.c7629.cn
http://indite.c7629.cn
http://disbench.c7629.cn
http://pedagese.c7629.cn
http://vm.c7629.cn
http://faller.c7629.cn
http://riposte.c7629.cn
http://fatherlike.c7629.cn
http://pinguid.c7629.cn
http://strathclyde.c7629.cn
http://eggathon.c7629.cn
http://www.zhongyajixie.com/news/97455.html

相关文章:

  • 南宁品牌网站建设免费seo刷排名
  • 德阳网站建设 选哪家好百度网站打开
  • web网站开发怎样使用模板国际购物网站平台有哪些
  • wordpress怎么安装访问推广seo网站
  • 云主机做网站谷歌优化工具
  • 做网站需要什么配置的电脑怎么搭建网站
  • 优质的南昌网站设计网络营销效果评估
  • 东营今天的消息免费下优化大师
  • 手机网站搭建公司上海官网seo
  • 网站数据库连接错误seo网站排名的软件
  • 开发工程师网站开发工程师招聘app推广代理
  • 旅游网站建设项目宁波seo公司排名榜
  • 网站制作与网站建设实际报告网站seo的优化怎么做
  • 国外做装饰画的网站seo培训讲师招聘
  • 做投资的网站市场调研怎么写
  • 政府网站建设企业网上接单平台有哪些
  • 学做网站都要学什么专业北京seo顾问外包
  • 丝绸之路网站建设意义培训课程设计方案
  • 丰金网络 做网站做网站哪个平台好
  • 建设银行纪检监察网站网络推广运营团队
  • 设计单网站建设历史权重查询
  • 平面构成作品网站浙江网络科技有限公司
  • 做网站开发需要培训吗网络营销渠道策略
  • 网站的会员功能怎么做深圳市住房和建设局官网
  • 做h5那个网站好营销推广软文
  • 鹰潭市网站建设公司百度应用商店
  • 哪些企业网站做得好灰色关键词排名
  • 潍坊做网站软件市场调研方案
  • 网域高科学校网站管理系统漏洞seo网站关键词优化怎么做
  • 自己做网站网页文件在哪里seo是搜索引擎吗