iframe和弹窗这些词对于js高手来说都是耳熟能详的东西,作为一个新人来说,还在学习阶段的我就在工作中遇到这么一个奇葩的需求,要在引入的iframe页面里做一个全屏化的功能.
粗略一看,这还不容易,模拟下F11的功能键什么的,于是网上一搜还真有一大堆关于全屏化的案例,遂借来用之.
然后高高兴兴的拿一个没有iframe引入的页面做了个测试页面查看全屏化功能效果,代码如下(fullScreenPage.html):
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Control Tower</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> </head> <body style="margin: 0px;height: 100%;width: 100%;"> <div id="buttonPanel" style="position: absolute;left: 25%;z-index:100"> <input id="full_screen_open" type="button" value="打开全屏"> <input id="full_screen_close" type="button" value="退出全屏" style="display: none"> </div> <div id="container" style="display:table;height: 50%;width: 50%;background-color: #004981;position:absolute;left: 25%;"> <div style="display:table-cell;height: 50%;width: 50%;text-align: center;vertical-align: middle;border: 2px solid #DDDDDD;"> <font id="font" size="30"></font> </div> </div> </body> <script src="/UploadFiles/2021-04-02/jquery-1.11.3.js">嗯,我自己觉得这个效果真的是不要太棒了,还做了浏览器兼容(FireFox=mozRequestFullScreen;W3C=requestFullscreen;Chrome等=webkitRequestFullScreen;ie11=msRequestFullscreen).....
于是,我立马放到项目里,结果是什么样子呢"htmlcode">
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Control Tower</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> </head> <body style="margin: 0px;height: 100%;width: 100%;"> <div id="parentContainer" style="height: 75%;width: 75%;position:absolute;left: 12.5%;border: 2px solid red;"> <!-- 蓝色边框以内的内容是引入的iframe页面内容,也是需要做全屏化功能的页面 --> <iframe src="/UploadFiles/2021-04-02/fullScreenPage.html">哦豁,好像没生效,那么为什么呢"htmlcode">
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Control Tower</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> </head> <body style="margin: 0px;height: 100%;width: 100%;"> <div id="buttonPanel" style="position: absolute;left: 25%;z-index:100"> <input id="full_screen_open" type="button" value="打开全屏"> <input id="full_screen_close" type="button" value="退出全屏" style="display: none"> </div> <div id="container" style="display:table;height: 50%;width: 50%;background-color: #004981;position:absolute;left: 25%;"> <div style="display:table-cell;height: 50%;width: 50%;text-align: center;vertical-align: middle;border: 2px solid #DDDDDD;"> <font id="font" size="30"></font> </div> </div> </body> <script src="/UploadFiles/2021-04-02/jquery-1.11.3.js">哈哈,改了之后发现果然可以了,问题解决。
jQuery还请自行下载并导入引用,我这里就不细说了.
这里分享一个jQuery下载的地址:jquery下载所有版本(实时更新)
以上所述是小编给大家介绍的jQuery中弹出iframe内嵌页面元素到父页面并全屏化的实现代码,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对网站的支持!
华山资源网 Design By www.eoogi.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
华山资源网 Design By www.eoogi.com
暂无评论...
更新日志
2024年09月25日
2024年09月25日
- 纯音入心系列纯音乐《天籁古筝》1CD[MP3][331MB]
- 男女对唱典藏天碟《发烧对唱·那个季节里的歌DSD》10CD[WAV]
- 群星2010-歌林精选辑[歌林][WAV+CUE]
- TrioZimbalist-PianoTriosofWeinberg,Auerbach,Dvorak(2024)[24-44,1]wav
- 群星.1992-滚石第一流台湾歌·12王牌大车拼【滚石】【WAV+CUE】
- 林子祥.1984-创作歌集【华纳】【WAV+CUE】
- 周汤豪.2010-周汤豪【华纳】【FLAC分轨】
- Mozart-TheStringQuintets-AmadeusQuartet,CecilAronowitz(2017)[24-44,1][WAV+CUE]
- JamesWilliamsDennisIrwin-Focus(2024,Red)[24-48]FLAC
- 藤泽麻衣《空みあげて》[WAV]
- 纯音入心系列纯音乐《中国古筝经典名曲》1CD[MP3][1.3GB]
- 纯音入心系列纯音乐《古筝新奏:岁月静好与筝语,细水流年与筝同》1CD[MP3][846.9MB]
- 670《脆弱敏感小女生》[320K/MP3][27.53MB]
- 曾琳.2011-好好爱我【南方】【WAV+CUE】
- 范晓萱.1995-RAIN【福茂】【WAV+CUE】